Load Html - Save to xls ignoring table formatting

Hi folks,

I have recently replaced the functionality to export html tables to Excel from one that simply set the response’s contentType to excel and then wrote the table to the Response with Apose.Cells. Prior to going the Aspose way the resulting worksheet was formatted as defined in the html table only now I get a worksheet with zero formatting.

Could someone tell me if I am doing something wrong as I am reallllllly close to a deadline and it’s looking like we may not be able to use Aspose. Any suggestions will be appreciated

Please see attached files:
table.txt is a file representation of the html being passed to the workbook constructor.
ResponseWriteResult.xls is the results before switching to Aspose.
AposeResult.xls is the results after switching to Aspose.

Code: (“Content” would be the contents of table.txt which is dynamic dependent upon the table being exported.)

context.HttpContext.Response.Buffer = true;
context.HttpContext.Response.Clear();
context.HttpContext.Response.ClearHeaders();
context.HttpContext.Response.ClearContent();
context.HttpContext.Response.AddHeader(“content-disposition”, “attachment; filename=”" + fileName + “”.xls");
context.HttpContext.Response.ContentType = “application/vnd.ms-excel”;

using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(Content)))
{
var loadOptions = new LoadOptions(LoadFormat.Html)
{
ConvertNumericData = false
};
var workbook = new Workbook(stream, loadOptions);

<span style="color:#93c763;">var</span> sheet <span style="color:#e8e2b7;">=</span> workbook<span style="color:#e8e2b7;">.</span>Worksheets[<span style="color:#ec7600;">"Sheet1"</span>];
sheet<span style="color:#e8e2b7;">.</span>AutoFitColumns();
sheet<span style="color:#e8e2b7;">.</span>AutoFitRows();
sheet<span style="color:#e8e2b7;">.</span>DisplayZeros <span style="color:#e8e2b7;">=</span> <span style="color:#93c763;">true</span>;

<span style="color:#93c763;">using</span> (<span style="color:#93c763;">var</span> ms <span style="color:#e8e2b7;">=</span> <span style="color:#93c763;">new</span> <span style="color:#678cb1;">MemoryStream</span>())
{
    workbook<span style="color:#e8e2b7;">.</span>Save(ms, <span style="color:#678cb1;">SaveFormat</span><span style="color:#e8e2b7;">.</span>Excel97To2003);
    ms<span style="color:#e8e2b7;">.</span>Position <span style="color:#e8e2b7;">=</span> <span style="color:#ffcd22;">0</span>;
    ms<span style="color:#e8e2b7;">.</span>WriteTo(context<span style="color:#e8e2b7;">.</span>HttpContext<span style="color:#e8e2b7;">.</span>Response<span style="color:#e8e2b7;">.</span>OutputStream);
}

}

Hi Simon,

Thanks for your posting and using Aspose.Cells for .NET.

We were able to observe this issue. When html is loaded into a workbook using Aspose.Cells, it loses the formatting. We have logged this issue in our database. We will look into it and resolve this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSNET-41979.

We have also attached the MS-Excel and Aspose output screenshot for comparison and reference.

Sample Code:


Workbook workbook = new Workbook(@“F:\Shak-Data-RW\Downloads\table.htm”);

workbook.Save(“output.xlsx”, SaveFormat.Xlsx);

Screenshot:

Hi Simon,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.0.2.3 and let us know your feedback.

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


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