Hi Team.
I am converting a range address into an image using a base64 string . However, whenever I retrieve the base64 string and save as png formate. I am facing issue.
In that image I’m getting some kind of id and Timestamp in that.
I am attaching problematic image as ActualResult.png and expected image as ExpectedResult.png .
Here is my code snippet
public async Task<dynamic> GetExcelRangeAsImage()
{
string excelPath ="my excel file path";
if (!string.IsNullOrEmpty(excelPath))
{
using (Aspose.Cells.Workbook wblob = new Aspose.Cells.Workbook(excelPath))
{
Aspose.Cells.Worksheet worksheet = wblob.Worksheets["Consolidado"];
if (worksheet != null)
{
worksheet.PageSetup.PrintArea = "A6:T10";
// Set all margins as 0
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.OnePagePerSheet = true;
options.ImageType = ImageType.Jpeg;
options.HorizontalResolution = 200;
options.VerticalResolution = 200;
SheetRender sr = new SheetRender(worksheet, options);
byte[] bytes = null;
using (MemoryStream st = new MemoryStream())
{
sr.ToImage(0, st);
bytes = st.ToArray();
}
File.WriteAllBytes(@"C:\Users\abc\Desktop\Image.png", bytes);
}
}
}
}
ImageIssue.zip (1.0 MB)