Reputation: 485
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();
}
}
Just trying this library ClosedXML.dll
, and it throws an exception can't figure out what could be the problem.
I get the _fName
from the savefiledialog
.
Ideas anybody?
Upvotes: 4
Views: 22706
Reputation: 636
I had fixed the same error after updating closedXML library. In other words, if ClosedXML and OpenXML are updated packages then this error will not occur.
Upvotes: 1
Reputation: 485
Thought would delete this post, but might help someone in future....All i had to do was reference one more DLL DocumentFormat.OpenXml.dll . Works perfectly now!
Upvotes: 11