public void OpenAndSearchDocument(string filePath, string xmlSplitDefinitionFilePath) { //split XML Read var xml = File.ReadAllText(xmlSplitDefinitionFilePath); Split splitXml; using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { XmlSerializer serializer = new XmlSerializer(typeof(Split)); splitXml = (Split)serializer.Deserialize(stream); } // Open a SpreadsheetDocumentDocument for editing using the filepath. SpreadsheetDocument wordprocessingDocument = SpreadsheetDocument.Open(filePath, true); // Assign a reference to the existing document body. Workbook body = wordprocessingDocument.WorkbookPart.Workbook; IMarkerMapper <Sheet> mapping = new MarkerExcelMapper(DocumentName, splitXml, body); //DocumentElements = mapping.Run(); // Close the handle explicitly. wordprocessingDocument.Close(); }
public void OpenAndSearchDocument(Stream excelFile, Stream xmlFile) { XmlSerializer serializer = new XmlSerializer(typeof(Split)); Split splitXml = (Split)serializer.Deserialize(xmlFile); using (SpreadsheetDocument excelDoc = SpreadsheetDocument.Open(excelFile, true)) { Workbook workBook = excelDoc.WorkbookPart.Workbook; IMarkerMapper <Sheet> mapping = new MarkerExcelMapper(DocumentName, splitXml, workBook); DocumentElements = mapping.Run(); } }