首页 > 解决方案 > 如何使用 XMLMap 和 EPPlus 导出 Excel 数据

问题描述

我想知道是否有人可以帮助我在 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?

谢谢

标签: c#xmlepplus

解决方案


推荐阅读