Dear Concern,
I’m trying to save the attached “temp.xlsx” worksheet as image.
But it throws error. We’ve found that Sparkline data is the cause of
error. If the marked sparklines in the attached image are cleared,
it works fine.
You are requested to fix the issue.
If fix takes time, please suggest us a workaround or at least would
you please inspect the source data of Sparkline and explain in which
condition the error throws, such that we could find out a workaround
as soon as possible to avoid the error.
The source code is given below, and necessary files are attached here.
var book = new Workbook("..\\..\\Template\\temp.xlsx");
var img = book.GetWorksheetImage();
public Image GetWorksheetImage(this Workbook workbook, string sheetName = “”, int pageIndex = 0)
{
var iop = new ImageOrPrintOptions
{
IsCellAutoFit = false,
ImageFormat = ImageFormat.Emf,
VerticalResolution = 96,
HorizontalResolution = 96,
Quality = 100,
OnePagePerSheet = true,
OnlyArea = true,
SaveFormat = SaveFormat.Auto,
ChartImageType = ImageFormat.Emf,
SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default
};
var sheet = string.IsNullOrWhiteSpace(sheetName)
? workbook.Worksheets[workbook.Worksheets.ActiveSheetIndex]
: workbook.Worksheets[sheetName];
var sr = new SheetRender(sheet, iop);
var imgOleObject = sr.ToImage(pageIndex);
return imgOleObject;
}
We are holding for this issue on a stage and cant go ahead. Eagerly
waiting for your response.