Hello again
I've attached 3 files:
- refresh xml.gif - shows the command, which I would like to execute without installing Excel
- test_order.xml - is the xml datasource, which is mapped in the file test_order_excel.xml
- test_order_excel.xml - is the excel xml template file, which contains a datasource, that uses the file test_order.xml
With an installed excel on my dev box, I can use the following code to update the xml datasource and save the new excel output file:
///
/// Opens an Excel XML File (Template), updates the XML Datasource and saves it as a new Excel XML File
///
/// The Excel XML Template File
/// The output Excel XML File
/// The XML Datasource File
public void MapXML(string pathToEmptyTemplate, string saveFilledTemplateToFullPath, string pathToXmlFile)
{
Excel.Application oXL = new Excel.Application();
Excel.Worksheet oSheet = new Excel.Worksheet();
try
{
oXL.Visible = false;
Excel.Workbook oWB = oXL.Workbooks.Open(pathToEmptyTemplate, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oWB.Worksheets[1];
Excel.XmlMap xmlMap1 = oWB.XmlMaps.get_Item(1);
oWB.XmlImport(pathToXmlFile, out xmlMap1, true, Type.Missing);
oWB.SaveAs(saveFilledTemplateToFullPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
oWB.Close(Type.Missing, Type.Missing, Type.Missing);
oXL.Quit();
System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("EXCEL");
foreach (System.Diagnostics.Process p in processes)
{
p.Kill();
}
}
catch (Exception ex)
{
System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("EXCEL");
foreach (System.Diagnostics.Process p in processes)
{
p.Kill();
}
throw ex;
}
}
But as already said, I'm not allowed to install Excel on our server.
Can you show me a way to do that with the Aspose.Cell library ? If yes, we'll buy it immediately!
Thank you very much!
Christian