using ClosedXML.Excel;
class XLSXWriter : BExporter
{
private readonly string _fName;
public XLSXWriter(string fileName)
{
_fName = fileName;
}
public override void Export(IEnumerable<AnimalData> animals)
{
var workBook = new XLWorkbook(); <---Throws an exception
var workSheet = workBook.Worksheets.Add("MySheet");
workSheet.Cell("A1").Value = "Hello World";
FileStream fs = new FileStream(_fName, FileMode.Create);
workBook.SaveAs(fs);
fs.Close();
}
}
只是尝试这个库ClosedXML.dll
,它会引发异常,无法弄清楚可能是什么问题。我_fName
从savefiledialog
. 任何人的想法?