public void SH003_ConvertTable(string name, string tableName) { FileInfo sourceXlsx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name)); var sourceCopiedToDestXlsx = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", "-1-Source.xlsx"))); if (!sourceCopiedToDestXlsx.Exists) { File.Copy(sourceXlsx.FullName, sourceCopiedToDestXlsx.FullName); } var dataXmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", "-2-Generated-XmlData.xml"))); using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true)) { var settings = new SmlToHtmlConverterSettings(); var rangeXml = SmlDataRetriever.RetrieveTable(sDoc, tableName); rangeXml.Save(dataXmlFi.FullName); } }
public void SH004_ConvertRange(string name, string sheetName, string range) { FileInfo sourceXlsx = new FileInfo(Path.Combine(TestUtil.SourceDir.FullName, name)); var sourceCopiedToDestXlsx = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", "-1-Source.xlsx"))); if (!sourceCopiedToDestXlsx.Exists) { File.Copy(sourceXlsx.FullName, sourceCopiedToDestXlsx.FullName); } var dataTemplateFileNameSuffix = string.Format("-2-Generated-XmlData-{0}.xml", range.Replace(":", "")); var dataXmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", dataTemplateFileNameSuffix))); using (SpreadsheetDocument sDoc = SpreadsheetDocument.Open(sourceXlsx.FullName, true)) { var settings = new SmlToHtmlConverterSettings(); var rangeXml = SmlDataRetriever.RetrieveRange(sDoc, sheetName, range); rangeXml.Save(dataXmlFi.FullName); } }
public void SH005_ConvertSheet(string name, string sheetName) { var sourceDir = new DirectoryInfo("../../../../TestFiles/"); var sourceXlsx = new FileInfo(Path.Combine(sourceDir.FullName, name)); var sourceCopiedToDestXlsx = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceXlsx.Name.Replace(".xlsx", "-1-Source.xlsx"))); if (!sourceCopiedToDestXlsx.Exists) { File.Copy(sourceXlsx.FullName, sourceCopiedToDestXlsx.FullName); } var dataTemplateFileNameSuffix = "-2-Generated-XmlData-Entire-Sheet.xml"; var dataXmlFi = new FileInfo(Path.Combine(TestUtil.TempDir.FullName, sourceCopiedToDestXlsx.Name.Replace(".xlsx", dataTemplateFileNameSuffix))); using var sDoc = SpreadsheetDocument.Open(sourceCopiedToDestXlsx.FullName, true); var settings = new SmlToHtmlConverterSettings(); var rangeXml = SmlDataRetriever.RetrieveSheet(sDoc, sheetName); rangeXml.Save(dataXmlFi.FullName); }