Hi 365,
Expecting the data to be bold, Underlined the cell field and Increase the data font while exporting the data to excel in D365 which is customized.
In other words am trying to export the data in excel through code, In this process am expecting the data to be format like bold the header, underlined the header and Increase the header data font to some extent in D365.
Could you please help me out on this.
Glad you got things sorted! :-)
If you found my answer helpful, please help the community by marking it as verified. This will help people with a similar question find the answer even faster.
Appreciate your time Michel and really helped provided articles.
The below code is for the bold, underlined & increasing the size of the font worked.
dynamicsaxgyan.wordpress.com/.../write-to-excel-using-x-code-ax-7d365-for-operations
From the above link to make "Account Number" bold, Underlined & Increase the size of the font...
Example code:
OfficeOpenXml.ExcelRange cell = cells.get_Item(currentRow, 1);
System.String value = "Account Number";
cell = cells.get_Item(currentRow, 1);
cell.set_Value(value);
//By assigning the class object and using to make it happen the required format.
Style.ExcelFont euSalesList = cell.Style.Font;
euSalesList.Bold = true;
euSalesList.Size = 16;
euSalesList.UnderLineType = true;
- Ram G
Hello Ram,
Looks like you are using a library (ExcelPackage [website, NuGet]) that has no real relation to Dynamics 365.
This might not be the best community to answer your question.
I tried to find the official documentation for this library but could only find the archived CodePlex website, CodePlex is unfortunately shut down, so any documentation that was posted there has been lost.
I did manage to find this article on someone who is also working with this library:
http://www.c-sharpcorner.com/blogs/how-to-format-excel-table-using-epplus-net-library-c-sharp-part-fifteen
There's a code sample with it that shows this:
ExcelPackage excelPkg = new ExcelPackage(); ExcelWorksheet wsSheet1 = excelPkg.Workbook.Worksheets.Add("Sheet1"); using(ExcelRange rng = wsSheet1.Cells["B2:I2"]) { rng.Value = "Everyday Be Coding - Format Table using EPPlus .Net Library - Part 15(B)"; rng.Style.Font.Size = 16; rng.Style.Font.Bold = true; rng.Style.Font.Italic = true; }
I'm unsure if this ExcelPackage library is still being maintained/updated. As an alternative, may I suggest the official libraries from Microsoft for generating Office documents: https://msdn.microsoft.com/en-us/library/office/ff478153.aspx
Or EPPPlus which is still under active development https://github.com/JanKallman/EPPlus
Hope this gives you a nudge in the right direction :-)
Thanks Michel,
dynamicsaxgyan.wordpress.com/.../write-to-excel-using-x-code-ax-7d365-for-operations
Am following the code and trying to make the cell in excel as bold, Underlined & Increasing the font.
- Ram G
Hello Ram,
If Excel Templates are not what you are looking for, I'm unsure what you mean. You mention making the text Bold, Underlined and increasing the font, which are all style options which you can do in Excel Templates.
Can you elaborate a little more on how you are trying to export to Excel exactly? You mentioned using code, what type of code are you using?
Are you using the SDK to export data and then generating an Excel document yourself? Generating your own Excel document would require you to use the properties of the library you are using for document creation to be set/changed.
Appreciate your reply Michel,
But not looking for the template or styled excel sheets.
Deliberately looking for the bold, underlined & Increasing the font.
- Ram G
Hello,
If you require custom formatting or formulas in your Excel exports, I suggest you look at Excel Templates.
This allows you to use a View in Dynamics 365 to export to a predefined and styled Excel sheet.
Essentially you download an styled Excel Template first, style it as you want, add colors, graphs, formulas, the works and then reupload it to Dynamics 365. The next time you want to export your data you can choose your own template and the data will be exported in the style you created.
Take a look at this article on how to create an Excel Template:
https://docs.microsoft.com/en-us/dynamics365/customer-engagement/marketing/manage-excel-templates
The article focuses mostly on creating graphs and pivot tables but, you can change anything in your template, including the boldness.