Good day people
I'm facing an issue with the XlsIO component where I cannot render an image of an excel file.
The excel file is not that complex, it's 1179 rows and less than 10 columns.
I don't intend to render an image of all that information, that's why I pass the 'lastColumn' and 'lastRow' capped at low values.
The code is the following, and the bold line never completes:
using (var fs = new FileStream(@"XlsIo.xlsx", FileMode.Open, FileAccess.Read))
{
using (Syncfusion.XlsIO.ExcelEngine engine = new Syncfusion.XlsIO.ExcelEngine())
{
Syncfusion.XlsIO.IApplication app = engine.Excel;
var workbook = app.Workbooks.Open(fs);
var worksheet = workbook.Worksheets[0];
var nrows = worksheet.UsedRange.LastRow;
var ncols = worksheet.UsedRange.LastColumn;
var image = worksheet.ConvertToImage(1, 1, nrows > 40 ? 40 : nrows,
ncols > 7 ? 7 : ncols, Syncfusion.XlsIO.ImageType.Bitmap, null);
MemoryStream ret = new MemoryStream();
image.Save(ret, ImageFormat.Png);
ret.Seek(0, SeekOrigin.Begin);
return ret;
}
}
I've tried with even smaller values at no avail.
I'm sending attached a console app sample project with just one method, which tries to load the xlsx file which is also attached.
I'm using Syncfusion.XlsIO.AspNet.Mvc5 version 19.4.0.48, the project is 32-bit and I cannot change it to 64bit because it's part of another solution already built on 32 bits.
Is this a bug, or known issue?
Thank you for your feedback, regards
Alex
Hello Ramya,
Thank you for your reply.
I deleted the images and the test project worked fine, but the problem is that I cannot modify the excel files since they're uploaded by users, so we are not in control of their creation.
As explained in the original message, I don't need a full/detailed image of the excel worksheet, just something like a preview to show to the users, that's why I capped the lastRow/lastColumn parameters, and the hidden images were far at the end of the file.
Also, the images seem to be small in size, I don't understand why they cause a complete hang of the conversion function. Shouldn't this be considered a bug?
Ramya, do you know a way to just ignore images and other embedded objects in the worksheet when calling ConvertToImage?
Thanks again, regards
Alex
|
using (var fs = new FileStream(@"XlsIo-Test.xlsx", FileMode.Open, FileAccess.Read))
{
using (Syncfusion.XlsIO.ExcelEngine engine = new Syncfusion.XlsIO.ExcelEngine())
{
Syncfusion.XlsIO.IApplication app = engine.Excel;
var workbook = app.Workbooks.Open(fs);
var worksheet = workbook.Worksheets[0];
var nrows = worksheet.UsedRange.LastRow;
var ncols = worksheet.UsedRange.LastColumn;
workbook.Worksheets.AddCopy(workbook.Worksheets[0], ExcelWorksheetCopyFlags.CopyAll & ~ExcelWorksheetCopyFlags.CopyShapes);
var tempSheet = workbook.Worksheets[2];
var image = tempSheet.ConvertToImage(1, 1, nrows > 40 ? 40 : nrows,
ncols > 7 ? 7 : ncols, Syncfusion.XlsIO.ImageType.Bitmap, null);
MemoryStream ret = new MemoryStream();
image.Save(ret, ImageFormat.Png);
ret.Seek(0, SeekOrigin.Begin);
return ret;
}
} |