How to add Gridlines for Excel > HTML converts

I would like to the option to add Gridlines to the output of files converted from excel related file types.
How can this be done?
I have not seen a way this is possible.

Hi,

Thanks for your posting and using Aspose.Cells.

This is not directly possible and also not supported by Microsoft Excel. But if you set the borders of all of your cells either manually with Microsoft Excel or dynamically using Aspose.Cells, then you will be able to show grid lines in your HTML export.

Please see the following sample code, source excel file, output html and screenshot showing the html for your reference.

The sample code loads your source excel file and applies Thin border on all of the cells inside your first worksheet and export the workbook in html format.

C#

//Directory path where your source file exists
string dirPath = @"D:\Downloads";

//Load your source excel file
Workbook workbook = new Workbook(dirPath + “source.xlsx”);

//Access your first worksheet
Worksheet worksheet = workbook.Worksheets[0];

//Creating a range of cells containing data
Range range = worksheet.Cells.CreateRange(0, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
//Creating a Style object to apply the borders to all cells
Style style = workbook.CreateStyle();
//Setting border for all sides of a cell
style.SetBorder(BorderType.LeftBorder, CellBorderType.Thin, Color.Black);
style.SetBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Black);
style.SetBorder(BorderType.TopBorder, CellBorderType.Thin, Color.Black);
style.SetBorder(BorderType.BottomBorder, CellBorderType.Thin, Color.Black);
//Applying the style to the range of cells
range.ApplyStyle(style, new StyleFlag() { Borders = true });

//Save the workbook in html format
workbook.Save(dirPath + “output.html”, SaveFormat.Html);

Hi,

Thanks for using Aspose.Cells.

We have supported this feature now. Now you will not have to use the workaround as suggested in the above post and you will be able to directly export your excel file into Html with Gridlines. We will provide you a fix soon. Once, the fix is available for you, we will notify you in this thread and provide you a download link.

Hi,

Please try our latest version/fix: Aspose.Cells for .NET (Latest Version)

Please note:

1) We have added HtmlSaveOptions.ExportGridLines property, indicating whether to export the gridlines. The default value is false.

2) See the .NET sample codes as follows:

Workbook wb = new Workbook(filePath + "source.xlsx");

HtmlSaveOptions options = new HtmlSaveOptions();

options.ExportGridLines = true;

wb.Save(filePath + "out.html", options);

Let us know your feedback.

Thank you.

The issues you have found earlier (filed as CELLSNET-44502) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.