Hello Aspose Team
Hi,
Thanks for your posting and using Aspose.Cells.
We have looked into your issue with the latest version:
Aspose.Cells for .NET (Latest Version) and found that it supports your requirements.
Please use the ImageOrPrintOptions.PixelFormat property for your needs.
C#
imgOptions.PixelFormat = PixelFormat.Format1bppIndexed;
when i try to set this on the save i have this exception:
Hi,
Thanks for your feedback and using Aspose.Cells.
We have tested this issue with the following sample code using the latest version:
Aspose.Cells for .NET v8.8.0.2
with the sample excel file
attached with this post and found it throws exception as you have mentioned.
We have logged this issue in our database for investigation. We will look into it and fix this issue. Once the issue is resolved or we have some other update for you, we will let you know asap.
This issue has been logged as
- CELLSNET-44418 - Save to Tiff - Using PixelFormat.Format1bppIndexed throws exception
I have also shown the exception generated by the code for a reference.
C#
Worksheet ws = wb.Worksheets[0];
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.SaveFormat = SaveFormat.TIFF;
opts.TiffCompression = TiffCompression.CompressionCCITT4;
opts.OnePagePerSheet = true;
opts.PixelFormat = PixelFormat.Format1bppIndexed;
SheetRender sr = new SheetRender(ws, opts);
sr.ToImage(0, “Test.tiff”);
Exception
HResult=-2146232832
Message=A Graphics object cannot be created from an image that has an indexed pixel format.
Source=Aspose.Cells
StackTrace:
at . (Int32 , ImageOrPrintOptions )
at . (Int32 , ImageOrPrintOptions , Stream )
at . (Int32 , ImageOrPrintOptions , Stream )
at . (Int32 , String , ImageOrPrintOptions )
at Aspose.Cells.Rendering.SheetRender.ToImage(Int32 pageIndex, String fileName)
at CellsNET.Program.f1() in d:\Aspose\Projects\NET\AsposeProject\CellsNET\Program.cs:line 59
at CellsNET.Program.Main(String[] args) in d:\Aspose\Projects\NET\AsposeProject\CellsNET\Program.cs:line 30
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Hi,
http://prntscr.com/b0igwa