Help in creating such Report from DataTable

Hi,

We have our system from which we want to different type of reports in the form of Excel Sheet. The data is retrieved in DataTables. We want a sample code that can help us generate report with columns as shown in the attached Excel sheet. We know that your documentation is too concise and detailed,but we are having problems setting the formatting of each cell and we will be thankful if a ready code could be provided to generate such Excel file from DataTable. Please note that each cell should be able to contain multiline strings e.g have a look at Activity field. We appreciate your instant feedback in this regard.Report Sample.zip (15.4 KB)

@Acton,

Thanks for the sample file.

I think you may first import your datatable to Excel spreadsheet via Aspose.Cells APIs, see the document for your reference:

Regarding formatting (e.g set font text bold, set text wrapped in the cells, etc.), once you have imported data from DataTable to Excel worksheet, you may create Style object(s) and specify your desired formatting attributes (you may also create StyleFlag object(s) and then set the relevant options on), then you may apply formatting to the whole row, complete range, column or cells for your needs, see the documents for your reference:

See the following code segment for your reference:
e.g
Sample code:

Worksheet _worksheet = workbook.Worksheets["Daily Brief Report"];
            //Create a style object
            Aspose.Cells.Style style = workbook.CreateStyle();
            //Set wrapping text on
            style.IsTextWrapped = true;
            //set the font text bold
            style.Font.IsBold = true;

            StyleFlag flag = new StyleFlag();
            flag.WrapText = true;
            flag.FontBold = true;
            //Apply the style to the header row (bold text and text is wrapped)
            _worksheet.Cells.ApplyRowStyle(0, style, flag);
            
           //Your code goes here.
           //...........
          //.........
           
            _worksheet.AutoFitRows();

Hope, this helps a bit.

Thank you.