How to save Worksheets in HTML- one below one

I want to save all the worksheets in an excel file in a single HTML file. By default, HTML file shows these worksheets as separate tabs in HTML. Instead, I want to save those one below one. Can you please suggest how can I achieve it?

Hi,


Thank you for using Aspose. Cells.

I am afraid there is not direct method for this purpose. But you can combine the data of all the worksheets in one worksheet and then save it as html for your requirements. Please visit this link for how to combine all the worksheets in one worksheet.

Hi,

You can refer to the following code for your requirements. It is the same as I have mentioned in the earlier post, except that at the end, the destination worksheet is saved as HTML. I have attached the Source Excel file as well for your reference.

string filePath = @“K:\sourcesheets.xls”;

Workbook workbook = new Workbook(filePath);

Workbook destWorkbook = new Workbook();

Worksheet destSheet = destWorkbook.Worksheets[0];

for (int i = 0; i < workbook.Worksheets.Count; i++)

{

Worksheet sourceSheet = workbook.Worksheets[i];

Range sourceRange = sourceSheet.Cells.MaxDisplayRange;

Range destRange = destSheet.Cells.CreateRange(sourceRange.FirstRow + TotalRowCount, sourceRange.FirstColumn,sourceRange.RowCount, sourceRange.ColumnCount);

destRange.Copy(sourceRange);

TotalRowCount = sourceRange.RowCount + TotalRowCount;

}

destWorkbook.Save(@“K:\output.html”, SaveFormat.Html);

Thanks a lot Kashif. It works for me :slight_smile:

Hi,


You are welcome. Please feel free to contact us if you have any additional query. We will try our best to assist you as soon as possible.

Also, we recommend you to download and use this latest version of Aspose.Cells: Aspose.Cells for .NET v7.2.2.7 in your applications.