如何使用XMLMap和EPPlus导出Excel数据

时间:2018-07-18 19:31:40

标签: c# xml epplus

我想知道是否有人可以帮助我在EPPlus或OpenOffice XML中实现以下C#代码:

Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();

string excelFileName = "Sample.xlsx";

string currentDirectory = Directory.GetCurrentDirectory();
string excelFilePath = System.IO.Path.Combine(currentDirectory, excelFileName);

app.Workbooks.Open(excelFilePath,
    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);
string xmlContent = string.Empty;

// Use the map (XSD inside the Excel file)
app.ActiveWorkbook.XmlMaps[1].ExportXml(out xmlContent);
app.Workbooks.Close();

使用Microsoft.Office.Interop.Excel.Application需要在服务器上安装Microsoft Office。除了安装Microsoft Engine之外,还有其他方法吗?基本上,如何在不使用office.Interop的情况下读取XMLMap?

谢谢

0 个答案:

没有答案