Can Aspose.Cells update XML DataSources?

Hi.

We have the following situation:
We have an XML File as a Datasource defined in an Excel Template File. Now we're looking for a possibility to update the Datasource and save the updated Excel File in a new path.

We could update the Datasource with two lines of code by installing Excel on our Server and using Interop Services, but we do NOT want to install Excel on our server!

Does Aspose.Cells offer a method to update the sheet with the current data in the XML Source File?

Thanks for your answers.

Hi,

If your xml file is in native excel format (e.g.., SpreadsheetML file), Aspose.Cells supports to update the file but it does not support to manipulate non - native excel formats currently.

By the way, could you post your template .xml file here, we will check your file soon.

Thank you.

Hello again

I've attached 3 files:

  1. refresh xml.gif - shows the command, which I would like to execute without installing Excel
  2. test_order.xml - is the xml datasource, which is mapped in the file test_order_excel.xml
  3. 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

Hi Christian,

Thanks for providing us the template files.

We will check and get back to you soon.

Thank you.

Hi Christian,

We do not support to map xml to xls file and update XML DataSources in the template file.

Please bind xml to DataSet or DataTable,then use Cells.ImportDataTable method to import data to xls file.