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,
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
Hi,