When Convert HTML content into Excel file by Aspose Cells:
The table style in HTML file is not working. Background color & Vertical-align & table border etc.
The Image file in html file also is not working.
Where can I find the detail document for Converting HTML to excel? I only found http://www.aspose.com/docs/display/cellsnet/Converting+HTML+files+to+Excel+Spreadsheets
Please share your HTML file which you are converting to Excel file. We will look into it if your HTML file is convertible or not. Please note, not all types of HTML can be converted to Excel file. Only Excel-Oriented HTML files can be converted to Excel file.
We have evaluated the presented scenario while using the latest revision of Aspose.Cells for .NET 8.7.1, and we are able to notice the problem as mentioned in point 1) of your original post, that is; formatting is getting lost while converting the HTML to spreadsheet format (we have tested by storing the result in XLSX file format). We have logged this incident as CELLSNET-44263 in our bug tracking system for further investigation and we require some time for proper analysis. Regarding point 2) from your original post, you haven’t shared the image that is being referenced in the HTML therefore we are not able to evaluate this case. Moreover, when we tried to convert the HTML with Excel application, the image is not being displayed in Excel generated XLSX as well. Please review the resultant spreadsheets in attachment.
I reviewed your attached 2 files. The “Excel-Saved.xlsx” is much better than “Aspose-Saved.xlsx”.
In “Excel-Saved.xlsx”, only the content is different with the html file in browser. If the content is vertical align middle, the export will be perfect.
But in Aspose-Save.xlsx", there are the following issues:
1. The title should be multiple lines (current 2 lines)
2. Table header color and background color is lost.
3. Table content is not vertical align middle.
4. Table column width issue, and the date content can’t be shown up.
5. The link in the table doesn’t work.
6. The company logo is not shown up. Our company logo is a jpg file (127*49)
I have logged your comments to the aforementioned ticket and have requested the concerned member of the product team to consider these points while investigating the matter. Regarding the point 6) as discussed earlier, the image isn’t visible in HTML either (due to the broken link as image is not available at specified location) therefore it will not be displayed in the resultant spreadsheet as well. It would be appropriate that you should share the image (Company_logo.jpg) so we could test this case with your sample entirely.
I am afraid, the ticket logged earlier as CELLSNET-44263 is currently unresolved. We have requested the concerned member of the product team to share the current status, and preferably an ETA for the fix. As soon as we get any news, we will post here for your kind reference.
Regarding the sample image, could you please state where and how you sent the image?
This is to update you that we will try our best to provide the fix for the ticket logged earlier as CELLSNET-44263 during the second week of May 2016. Thank you for your patience with us.
About CELLSNET-44263, there are some information for you:
1. About the details of the problem. We have fixed 1, 2, 4, 5 and 6.
Details of the problem 1. The title should be multiple lines (current 2 lines) 2. Table header color and background color is lost. 3. Table content is not vertical align middle. 4. Table column width issue and the date content can’t be shown up. 5. The link in the table doesn’t work. 6. Font size is changed
About table content is not vertical align middle. It is same as MS-Excel for now. It is complicated, we will fix it later.
2. Please use the following code:
C#
Workbook wb = new Workbook(“listingreport.html”); wb.Worksheets[0].AutoFitRows(); wb.Worksheets[0].AutoFitColumns(); wb.Save(“out.xlsx”);
Please try the latest version of Aspose.Cells for .NET (Latest Version) for the remaining issues of the ticket CELLSNET-44263. Please let us know your feedback so we could close the aforementioned ticket.
Cannot show the images correctly after export html to excel.
Cannot export all html content to excel,especially when the html has nested elements.
B) Here is the code I used to test:
private void button1_Click(object sender, EventArgs e)
{
var export_html = @"
7/21-2 full
Admin_O_F Admin_O_L
abc@abc.com
1234567890
ABC DEF
Generated OnMay 30, 2016 02:33 PM
Time Call Received from Jan 01, 2016 to May 30, 2016
";
using (MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(export_html)))
{
Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions(Aspose.Cells.LoadFormat.Html);
//use the stream here and don’t worry about needing to close it
Workbook wb = new Workbook(ms, loadOptions);
wb.Worksheets[0].AutoFitRows();
wb.Worksheets[0].AutoFitColumns();
var worksheet = wb.Worksheets[0];
wb.Save(“c:\test2.xlsx”, Aspose.Cells.SaveFormat.Xlsx);
}
}
C) The attached files :
Screenshot of the results, expected results VS actually results.
Thank you for sharing your feedback. We have evaluated the recently shared scenario against the latest revision of Aspose.Cells for .NET 8.8.1.2 and we are able to replicate both issues. In order to further investigate the matter, we have logged 2 tickets against the mentioned issues. Please find the below details for your future reference.
CELLSNET-44466: Cannot show the images correctly after export HTML to spreadsheet
CELLSNET-44467: Cannot export all HTML content to spreadsheet when the HTML has nested elements
Please spare us little time to properly investigate the aforementioned issues and get back to you with updates in this regard.
It is to inform you that we have fixed your issue CELLSNET-44467 now. We will soon provide the fix after performing QA and including other enhancements and fixes.
About CELLSNET-44467 , there are some tips for you.
The fix adds HTMLLoadOptions.SupportDivTag property
Indicates whether to support the layout of
tag when the html file contains
tags. The default value is false.
The sample code is as follow:
C#
var export_html = @"
7/21-2 full
Admin_O_F Admin_O_L
[abc@abc.com](mailto:abc@abc.com)
1234567890
ABC DEF
Generated OnMay 30, 2016 02:33 PM
Time Call Received from Jan 01, 2016 to May 30, 2016
";
using (MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(export_html)))
{
Aspose.Cells.HTMLLoadOptions loadOptions = new HTMLLoadOptions(LoadFormat.Html);
loadOptions.SupportDivTag = true;
//use the stream here and don’t worry about needing to close it
Workbook wb = new Workbook(ms, loadOptions);
wb.Worksheets[0].AutoFitRows();
wb.Worksheets[0].AutoFitColumns();
var worksheet = wb.Worksheets[0];
wb.Save(filePath + “source.xlsx”, Aspose.Cells.SaveFormat.Xlsx);
}