Devika M

Devika M

  • 2k
  • 39
  • 873

Convert Excel to HTML

Jul 15 2020 2:30 AM
I have a requirement to preview excel files in browser. I am currently trying to convert excel file to html using the OpenXML SDK and OpenXml Power tool. Using the SmlDataRetriever I could retrieve the XElement data from the excel sheet but I am unable to proceed further. Please find below the format which I receive from SmlDataRetriever
  1. <Data>  
  2. <DataProps>  
  3. <sheetFormatPr defaultColWidth="9.25" defaultRowHeight="15" dyDescent="0.25" />  
  4. </DataProps>  
  5. <Row RowNumber="1">  
  6. <Cell Ref="A1" ColumnId="A" ColumnNumber="0" Type="s">  
  7. <CellProps />  
  8. <Value>Make </Value>  
  9. <DisplayValue>Make </DisplayValue>  
  10. </Cell>  
  11. <Cell Ref="B1" ColumnId="B" ColumnNumber="1" Type="s">  
  12. <CellProps />  
  13. <Value>Miles </Value>  
  14. <DisplayValue>Miles </DisplayValue>  
  15. </Cell>  
  16. <Cell Ref="C1" ColumnId="C" ColumnNumber="2" Type="s">  
  17. <CellProps />  
  18. <Value>Cost</Value>  
  19. <DisplayValue>Cost</DisplayValue>  
  20. </Cell>  
  21. </Row>  
  22. <Row RowNumber="2">  
  23. <Cell Ref="A2" ColumnId="A" ColumnNumber="0" Type="s">  
  24. <CellProps />  
  25. <Value>Ford</Value>  
  26. <DisplayValue>Ford</DisplayValue>  
  27. </Cell>  
  28. <Cell Ref="B2" ColumnId="B" ColumnNumber="1">  
  29. <CellProps />  
  30. <Value>40000</Value>  
  31. <DisplayValue>40000</DisplayValue>  
  32. </Cell>  
  33. <Cell Ref="C2" ColumnId="C" ColumnNumber="2" Style="1">  
  34. <CellProps numFmtId="6" formatCode=""$"#,##0_);[Red]\("$"#,##0\)" applyNumberFormat="1">  
  35. <font>  
  36. <sz val="11" />  
  37. <color theme="1" />  
  38. <name val="Calibri" />  
  39. <family val="Swiss" />  
  40. <scheme val="minor" />  
  41. </font>  
  42. </CellProps>  
  43. <Value>3500</Value>  
  44. <DisplayValue>$3,500</DisplayValue>  
  45. </Cell>  
  46. </Row>  
  47. <Row RowNumber="3">  
  48. <Cell Ref="A3" ColumnId="A" ColumnNumber="0" Type="s">  
  49. <CellProps />  
  50. <Value>Chevi</Value>  
  51. <DisplayValue>Chevi</DisplayValue>  
  52. </Cell>  
  53. <Cell Ref="B3" ColumnId="B" ColumnNumber="1">  
  54. <CellProps />  
  55. <Value>55000</Value>  
  56. <DisplayValue>55000</DisplayValue>  
  57. </Cell>  
  58. <Cell Ref="C3" ColumnId="C" ColumnNumber="2" Style="1">  
  59. <CellProps numFmtId="6" formatCode=""$"#,##0_);[Red]\("$"#,##0\)" applyNumberFormat="1">  
  60. <font>  
  61. <sz val="11" />  
  62. <color theme="1" />  
  63. <name val="Calibri" />  
  64. <family val="Swiss" />  
  65. <scheme val="minor" />  
  66. </font>  
  67. </CellProps>  
  68. <Value>4200</Value>  
  69. <DisplayValue>$4,200</DisplayValue>  
  70. </Cell>  
  71. </Row>  
  72. <Row RowNumber="4">  
  73. <Cell Ref="A4" ColumnId="A" ColumnNumber="0" Type="s">  
  74. <CellProps />  
  75. <Value>Tata</Value>  
  76. <DisplayValue>Tata</DisplayValue>  
  77. </Cell>  
  78. <Cell Ref="B4" ColumnId="B" ColumnNumber="1">  
  79. <CellProps />  
  80. <Value>51000</Value>  
  81. <DisplayValue>51000</DisplayValue>  
  82. </Cell>  
  83. <Cell Ref="C4" ColumnId="C" ColumnNumber="2" Style="1">  
  84. <CellProps numFmtId="6" formatCode=""$"#,##0_);[Red]\("$"#,##0\)" applyNumberFormat="1">  
  85. <font>  
  86. <sz val="11" />  
  87. <color theme="1" />  
  88. <name val="Calibri" />  
  89. <family val="Swiss" />  
  90. <scheme val="minor" />  
  91. </font>  
  92. </CellProps>  
  93. <Value>3800</Value>  
  94. <DisplayValue>$3,800</DisplayValue>  
  95. </Cell>  
  96. </Row>  
  97. </Data>  
Is there any possible ways to convert this into a valid HTML so that it can be previewed. Is there any other methods in which this can be achieved. I cannot use the paid libraries for this work. I could not find any examples in the XSLT transformation of excel XML to HTML. Any help in this area is appreciated. TIA

Answers (6)