Hi,
I'm using syncfusion XlsIo to export image to Excel.
My original program supported this feature only to Excel 2003 and under which is a .xls file, and it worked fine.
However, now I'm trying to export the same thing to Excel 2007 which is a .xlsx file, and it ls not working.
Thank you in advance.
Here's the source code.
--------------------------------------------------------------------------------
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook sourceWorkbook = null;
sourceWorkbook = application.Workbooks.Add();
if (sourceWorkbook.Worksheets.Count == 3)
{
sourceWorkbook.Worksheets[2].Remove();
sourceWorkbook.Worksheets[1].Remove();
}
IWorksheet sheet = sourceWorkbook.Worksheets[0];
if (image != null)
{
IPictureShape pic = sheet.Pictures.AddPicture(1, 1, image); // image is Bitmap
}
sourceWorkbook.Version = ExcelVersion.Excel2007;
sourceWorkbook.SaveAs(xlsFileName);
sourceWorkbook.Close();
excelEngine.Dispose();
--------------------------------------------------------------------------------
Here's the Error Message
--------------------------------------------------------------------------------
System.ArgumentNullException: Value cannot be null.
Parameter name: encoder
Location: System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SaveImage(Image image, ImageFormat imageFormat, String proposedPath)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SaveImage(Image image, String proposedPath)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SerializeBSE(MsofbtBSE bse)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SaveWorkbookImages()
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SaveWorkbook(ExcelSaveType saveAsType)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SaveDocument(ExcelSaveType saveType)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SaveDocument(Stream stream, ExcelSaveType saveType)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.SaveDocument(String filename, ExcelSaveType saveType)
Location: Syncfusion.XlsIO.Implementation.XmlSerialization.FileDataHolder.Serialize(String fullName, WorkbookImpl book, ExcelSaveType saveType)
Location: Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(String FileName, ExcelSaveType saveType, ExcelVersion version)
Location: Syncfusion.XlsIO.Implementation.WorkbookImpl.SaveAs(String FileName)