Hi,
I am trying to use syncfusion XlsIO component to build Excel from Html table HTML table is built by code on the fly. Some text has ; (semicolon) in the <font> tag, which is failing while using ImportHtmlTable with following error.
Error:
<html>
<head>
<title>AMC</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style='border-collapse:collapse;'>
<tr>
<td>
<b>Buyer:</b> Sample Buyer
</td>
</tr>
<tr>
<td>
<font Style="font-size:8.0pt">716-224 Adding Semicolon in the font tag caused error; when there is a style attribute within a font tag. If style is removed, it works too</font>
If the semicolon without the font tag, it workes fine; -- this is working good
</td>
</tr>
</table>
</body>
</html>
Hi, I think the issue is there is a missing ; in the style attribute. When I add that it works fine.
Also - can you tell me how to set the Excel Column/Cell data format in html? say, I want to set certain column number type and others general and may be others in currency. Is that possible to set in the HTML styling ?
Thanks Keerthi! Also, is there an efficient way to achieve below step?
Dim lastRow As Int32 = worksheet.UsedRange.LastRow
Dim rng As IRange = worksheet.Range("F7:F" & lastRow.ToString())
rng.CellStyle.Font.Bold = True
Excel has XlUp and XlDown to find an end cell in a range, is that supported by XLSIO API?
Thanks.
Sunil
worksheet.UsedRange.CellStyle.Font.Bold = True |
Thank you Keerthi for the response! When I use a range to update format, it is extremely slow. Any suggestion how to optimize it?
Dim worksheet As IWorksheet = workbook.Worksheets(0)
Dim usedRange As IRange = worksheet.UsedRange
Dim rowCount As Integer = usedRange.LastRow
Dim colCount As Integer = usedRange.LastColumn
Dim migrantRange As IMigrantRange = worksheet.MigrantRange
Dim row As Integer
Dim column As Integer
For row = 1 To rowCount Step 1
For column = 1 To colCount Step 1
migrantRange.ResetRowColumn(row, column)
migrantRange.CellStyle.Font.Bold = True
Next
Next |
Thanks Keerthi! I will try this and let you know if any issues. I keep running into parsing error with importing data into HTML table format. Now the issue is when a value has '&' symbol in it. This is the error I am getting and the value is is error out: Please advise, if should try alternative solution instead of importing data into HTML and then excel.
HTML Value -
<td align="left" class="xl25">Food & Oils Company</td>
Error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: An error occurred while parsing EntityName. Line 1072, position 68.
Source Error:
|
|
Query |
Response |
Please advise, if should try alternative solution instead of importing data into HTML and then excel. |
You can directly import data from Data table to Excel instead of importing into HTML.
Please look into following link to Import data to Excel.
|
<td align="left" class="xl25">Food & Oils Company</td> |