Is it possible to read a XML file using Aspose?

Hi,

Is it possible to read a XML file using Aspose?

Thanks


This message was posted using Aspose.Live 2 Forum

Hi Vineet,

An XML file can be read to fill a datatable/dataset using ADO.NET APIs and then import the datatable to the worksheet using Aspose.Cells APIs.

Sample code is as follows,

DataSet ds = new DataSet();
FileStream fs = new FileStream("d:\\test\\xdata.xml",FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells.ImportDataTable(ds.Tables[0],true,"A1");
Thanks

Hi Vineet,

Aspose.Cells for .Net also supports reading / writing SpreadSheetML (.xml) files directly. SpreadSheetML files are the XML representations of Spreadsheets including all information about the Spreadsheet such as formatting, formulae etc.

You can read a SpreadSheetML file through sample code as given below,

Aspose.Cells.LoadOptions lOption = new Aspose.Cells.LoadOptions(Aspose.Cells.LoadFormat.SpreadsheetML);
Aspose.Cells.Workbook workbook = new Workbook("D:\\test_SpredSheetML.xml", lOption);

How to find out if XML is an spreadsheet representation?

I just have a XML file and I don't know if it is an spreadsheetML. Please advise.

Also, I want the way to read XML using Aspose.Cells for Java and not DotNet.

Hi,

We have a class CellsHelper.DetectFileFormat() in Aspose.Cells for .NET version, which can identify the file format. e.g



C#


string path = @“F:\Downloads\issue\MySource.xml”;

FileFormatType fmtType= CellsHelper.DetectFileFormat(path);

Debug.Write(fmtType.ToString());



Output:

Excel2003XML



But when I looked into Aspose.Cells for Java version, this class is not available.

So, I have added a request for it CELLSJAVA-25400.



FYI:
Please also see this document relating to SpreadsheetML Spreadsheets.


Hi,

Please try Aspose.Cells for Java v2.5.2.8.

In the new fix we have provided new methods:

CellsHelper.detectFileFormat(InputStream) and CellsHelper.detectFileFormat(String file)

Thank you.




The issues you have found earlier (filed as 25400) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.