public static XElement ConvertTableToHtml(SpreadsheetDocument sDoc, SmlToHtmlConverterSettings settings, string tableName) { var rangeXml = SmlDataRetriever.RetrieveTable(sDoc, tableName); var xhtml = SmlToHtmlConverter.ConvertToHtmlInternal(sDoc, settings, rangeXml); return(xhtml); }
// *********************************************************************************************************************************** #region PublicApis public static XElement ConvertTableToHtml(SmlDocument smlDoc, SmlToHtmlConverterSettings settings, string tableName) { using (MemoryStream ms = new MemoryStream()) { ms.Write(smlDoc.DocumentByteArray, 0, smlDoc.DocumentByteArray.Length); using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(ms, false)) { var rangeXml = SmlDataRetriever.RetrieveTable(sDoc, tableName); var xhtml = SmlToHtmlConverter.ConvertToHtmlInternal(sDoc, settings, rangeXml); return(xhtml); } } }
static void Main(string[] args) { FileInfo fi = null; fi = new FileInfo("../../SampleSpreadsheet.xlsx"); // Retrieve range from Sheet1 XElement data = SmlDataRetriever.RetrieveRange(fi.FullName, "Sheet1", "A1:C3"); Console.WriteLine(data); // Retrieve entire sheet data = SmlDataRetriever.RetrieveSheet(fi.FullName, "Sheet1"); Console.WriteLine(data); // Retrieve table data = SmlDataRetriever.RetrieveTable(fi.FullName, "VehicleTable"); Console.WriteLine(data); }