0

I have a web application that reads from XML, but the users need to upload .xlsx or .xls files.

How do I programatically convert the Excel files into XML spreadsheet 2003?

bernhof
  • 6,219
  • 2
  • 45
  • 71
Franco
  • 1
  • 1
  • 1

2 Answers2

2

I suggest you take a look at a similar question here on stackoverflow. The following alternatives are mentioned (among others):

  • NPOI which is free and open source
  • Aspose, in your case Apose.Cells, although it is definitely not free

I have no experience with either of these.

Using Microsoft Office Interop assemblies is not an option - it just won't work:

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

Community
  • 1
  • 1
bernhof
  • 6,219
  • 2
  • 45
  • 71
-3

You can read an existing excel file and save it into required format: xlXMLSpreadsheet.

Below is the sample code:

Microsoft.Office.Interop.Excel.Application app = 
    new Microsoft.Office.Interop.Excel.Application();
Workbook wb = app.Workbooks.Open("D:\\sample.xlsx");
wb.SaveAs("D:\\sample.xml", FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlXMLSpreadsheet);
wb.Close();
app.Quit();
bernhof
  • 6,219
  • 2
  • 45
  • 71
suresh
  • 38
  • 2
  • -1 Using Office interop assemblies on a web server is a really bad idea. See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757 – bernhof Jun 07 '13 at 12:30