I am converting Excel(One worksheet) to html and then inserting this html into word(using builder.inserthtml) in order to maintain all fonts/styles/colors. The excel sheet has some hidden rows, that I would like to embed inside the word document (not visibly), but they should appear in Design Mode in the word document, or Show/Hiding hidden text . When I set ExportActiveWorksheetOnly = true (when converting excel to html in HTMLSaveoptions) , I get the output in Word (after insertion) to not display Hidden rows - even in design mode. if I set it to false, they do appear (when in design mode) however, it also has the rest of the workbook which I do not want(I only want the one worksheet i selected).
I tried unhiding all rows in excel. then doing the conversion, and then trying to hide the rows again in word using run.font.hidden , however, this only hides the text and not the borders. If I clear the borders, then they will deleted from the document and will not appear when in Design Mode.
Basically to sum it up - I need to Convert Excel sheet to html then insert to Word doc. The excel sheet contains some hidden rows that I need to be able to view in Design Mode(in my word document). But not see them visibly in Word - without design mode. How can I accomplish this?
@prodigy234 In DOCX table row is marked as hidden as the following :
<w:trPr>
<w:hidden/>
</w:trPr>
Unfortunately, there is no public API to set this property.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-25899
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
do you know if there is potentially another way to accomplish this? either hiding a row in word or inserting a hidden row into word from html(height=0) - to view in design mode.
I found a solution. I first unhide all the excel rows in the excel sheet(store their row indices in a list - hiddenRows ). Convert to html. insert into word. Once in word doc, I do this
Access the table
Table table = (Table)doc.GetChild(NodeType.Table, tableNum, true);
Loop through rows, set these properties (if row # is in list of hiddenRows from excel)
row.RowFormat.Height = 0;
row.RowFormat.HeightRule = HeightRule.Exactly;
row.RowFormat.AllowBreakAcrossPages = false;
loop through cells, set these properties
cell.CellFormat.Borders.Top.LineWidth = 0;
cell.CellFormat.Borders.Left.LineWidth = 0;
cell.CellFormat.Borders.Bottom.LineWidth = 0;
cell.CellFormat.Borders.Right.LineWidth = 0;
then loop through all runs in paragraph node, set font to hidden
foreach (Paragraph paragraph in cell.GetChildNodes(NodeType.Paragraph, true))
{
foreach (Run run in paragraph.GetChildNodes(NodeType.Run, true))
{
run.Font.Hidden = true;
}
}
@prodigy234 It is perfect that you managed to achieve what you need. I tested with a simple HTML and the following HTML produces hidden row:
<html>
<body>
<table>
<tr>
<td>First</td>
<td>First</td>
<td>First</td>
</tr>
<tr>
<td><span style="display:none">Second</span></td>
<td><span style="display:none">Second</span></td>
<td><span style="display:none">Second</span></td>
</tr>
<tr>
<td>Third</td>
<td>Third</td>
<td>Third</td>
</tr>
</table>
</body>
</html>