Please see attached file and coding used.
static bool SaveExcelFile(string oldName)
{
bool saveStatus;
var newName = oldName.Replace("Inbox", "Batch");
var newFileInfo = new FileInfo(newName);
newName = newName.Replace(newFileInfo.Extension, "_pgnum.tif");
try
{
var imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions
{
ImageFormat = ImageFormat.Tiff,
HorizontalResolution = 200,
VerticalResolution = 200,
TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionCCITT4,
OnePagePerSheet = true
};
var saveExcelWorkbook = new Aspose.Cells.Workbook(oldName);
var saveWorksheetColl = saveExcelWorkbook.Worksheets;
var wsCount = saveWorksheetColl.Count;
for (int ws = 0; ws < wsCount; ws++)
{
var sheet = saveWorksheetColl[ws];
if (sheet.Cells.Count == 0 || sheet.CodeName == "Look ups"
|| sheet.CodeName == "Instructions for use"
|| sheet.CodeName == "Internal Instructions"
|| sheet.CodeName == "Autouploader" || !sheet.IsVisible)
{
continue;
}
sheet.ViewType = Aspose.Cells.ViewType.NormalView;
var wsRender = new Aspose.Cells.Rendering.SheetRender(sheet, imgOptions);
var saveName = newName.Replace("_pgnum", "_" + ws.ToString("00"));
wsRender.ToTiff(saveName);
}
saveStatus = true;
}
catch (Exception exc)
{
Console.WriteLine("Exception converting Excel Doc to TIF - {0}", exc.Message);
Log.Error(oldName, "Exception converting Excel Doc to TIF", exc.Message);
saveStatus = false;
}
GC.Collect();
return saveStatus;
}