开发者

Are there any third-party tools which allow importing XML data into Excel?

We are currently working on an application that has been using COM Interop in C# to import data into an Excel workbook. This data is fairly complex and lengthy, so we have been using the Import from XML feature in Excel. Because of the issues with running Excel on a server, we are now looking into moving to a 3rd-party solution for our workbook creation, such as SpreadsheetGear or Aspose.

SpreadsheetGear and Aspose do not support XML Import. Does anyone know of another 3rd-party, server-friendly tool that does?

--Edit-- The data is coming from an DB2 database that we are putting into C# classes and then serializing into XML. We are then importing the XML into around 30 tables and other cells. Then we copy and paste the tables to an output sheet and reuse the originals to import more.

--Edit-- The output is a form with multiple tables and fields on one sheet. Part of what the XML map helps with is keeping track of the 开发者_开发技巧locations of the cells, without having to massively hard-code cell-coordinates into the code.


You could look at SSIS. This has the facility where you can set XML as a datasource and a spreadsheet as a destination. (Or vice-versa).


EPPlus is a pretty good library but i'm not sur you can import XML directly, but you can import csv file directly, there are example in the samples.

It would still be fairly easy to implement.


Although I have not found a 3rd party tool that allows this functionality, Aspose.Cells has a "Smart Marker" feature that allows you to designate specific cells in a way similar to an XML map. I believe this may be the solution I have been looking for.


Load the XML into a dataset then use EPPlus to take the datatable out of excel and create an excel file from it:

DataSet ds = new DataSet();
            DataTable dt = ds.Tables[0];
            using (ExcelPackage pck = new ExcelPackage())
            {
                //Create the worksheet
                ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Calls");

                //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                ws.Cells["A1"].LoadFromDataTable(dt, true);

                Byte[] bin = pck.GetAsByteArray();

                string file = filePath;
                File.WriteAllBytes(file, bin);

            }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜