We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

CSV to TIFF rendering - Unable to convert csv/excel file completely in .NET

Hi Aspose Team,

We have an issue while converting excel /csv file with more than 640 rows of data to tiff .
We have found that the excel /csv would convert the file to tiff if the excel/csv contains less than 640 rows of data ,and any data more than 640 rows are lost(not getting converted).
Please find the attachment used to convert excel/csv to tiff SampleFile.zip (491 KB)

@bindu16abraham,
We have tried this scenario using the latest version but could not reproduce this issue. Could you please share your runnable sample code, product version, OS and other environment details? We will try to reproduce the issue and share our feedback accordingly.

Hi Ahsan,

We are using the aspose version :19.9
OS :Windows 10
Im pasting the code which is been used to convert document to tiff
ExcelSheetMultitiffs =ConvertExcelToTiff(MultiTiffFolder,fInfo.FullName,password);

public static List ConvertExcelToTiff(string OutputFolder, string FullInputFileName, string password)
{​​​​​
//onepage variable is use to manage large excel file.
List fullconvertedMultiTiffName = new List();
Workbook workbook = null;
WorksheetCollection sheets = null;
bool onepage = true;
try
{​​​​​
int sheetCount = 1;
//Initialize a new Workbook
Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions();
loadOptions.Password = password;
loadOptions.MemorySetting = MemorySetting.MemoryPreference;
workbook = new Workbook(FullInputFileName, loadOptions);

            workbook.Save(FullInputFileName);
       
            sheets = workbook.Worksheets;
            //For email FTP
    if (sheets.Count >=Convert.ToInt32(ConfigurationManager.AppSettings["SheetCount"].ToString()))
            {​​​​​
                onepage = false;
            }​​​​​
            foreach (Worksheet sheet in sheets)
            {​​​​​
                //sheet.Cells.DeleteBlankRows();
                //sheet.Cells.DeleteBlankColumns();
                if (sheet.Cells.Count == 0 && sheet.Pictures.Count == 0)
                    continue;
                if (!sheet.IsVisible)
                    continue;
                //Apply different Image and Print options 
                ImageOrPrintOptions options = new ImageOrPrintOptions();
                //Set Horizontal Resolution
                options.HorizontalResolution = 300;
                //Set Vertical Resolution
                options.VerticalResolution = 300;
                //Set TiffCompression
                options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionCCITT4;
                //Set Autofit options
                options.IsCellAutoFit = false;
                //Set Image Format
                options.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;
                //Set printing page type
                options.PrintingPage = PrintingPageType.Default;
                sheet.AutoFitColumns();
                sheet.AutoFitRows();
                //Render the sheet with respect to specified image/print options
                SheetRender sr = new SheetRender(sheet, options);
               
                if (sheet.Pictures.Count >= 1)
                {​​​​​
                    Picture pic = sheet.Pictures[0];
                    pic.FormatPicture.Brightness = 1.0F;
                }​​​​​
              
                string SheetName = String.Concat("Sheet", sheetCount.ToString());
                string FullSheetName = Path.Combine(Path.GetDirectoryName(FullInputFileName), SheetName);
                int pageCount = Convert.ToInt32(ConfigurationManager.AppSettings["ExcelPage"].ToString());
                //commented by shine
                if (sr.PageCount < pageCount)
                    pageCount = sr.PageCount;
                //if (sr.PageCount > pageCount || onepage == false)
                //{​​​​​
                //    sr.ToImage(1, FullSheetName + 1 + ".tiff");
                //    fullconvertedMultiTiffName.Add(FullSheetName + 1 + ".tiff");


                //}​​​​​
                //else
                if(sr.PageCount  > 0)
                {​​​​​
                    //for (int i = 0; i < sr.PageCount; i++)
                    for (int i = 0; i < pageCount; i++)
                    {​​​​​



                        //sr.ToImage(0, FullSheetName);
                        sr.ToImage(i, FullSheetName + i + ".tiff");
                        fullconvertedMultiTiffName.Add(FullSheetName + i + ".tiff");
                    }​​​​​




                }​​​​​


                sheetCount++;
            }​​​​​
        }​​​​​

public static void ResizeLargeImage(Shape image)
{
if (!image.HasImage)
return;
PageSetup ps = image.ParentParagraph.ParentSection.PageSetup;
double freePageWidth = image.IsInline ? ps.PageWidth - ps.LeftMargin - ps.RightMargin : ps.PageWidth;
double freePageHeight = image.IsInline ? ps.PageHeight - ps.TopMargin - ps.BottomMargin : ps.PageHeight;
ImageSize size = image.ImageData.ImageSize;
Boolean exceedsMaxPageSize = size.WidthPoints > freePageWidth || size.HeightPoints > freePageHeight;
if (exceedsMaxPageSize)
{
Boolean widthLonger = (size.WidthPoints > size.HeightPoints);
double ratio = widthLonger ? freePageWidth / size.WidthPoints : freePageHeight / size.HeightPoints;
image.Width = size.WidthPoints * ratio;
image.Height = size.HeightPoints * ratio;
}

    }

@bindu16abraham,

Since you are using an older version of the product (Aspose.Cells for .NET v19.9), so we cannot evaluate your issue using your older version that you are using. We evaluate issues using latest versions of the APIs. I simplified your code segment a bit to make it runnable. I used the following sample code using your CSV file (I used it as a template file) with Aspose.Cells for .NET v21.8.x (please try it), it works absolutely fine with it:
e.g.
Sample code:

 TxtLoadOptions opts = new TxtLoadOptions(LoadFormat.Csv);
 workbook = new Workbook("e:\\test2\\202109038000015.000.csv", opts);
 sheets = workbook.Worksheets;
 foreach (Worksheet sheet in sheets)
 {​​​​​
                //sheet.Cells.DeleteBlankRows();
                //sheet.Cells.DeleteBlankColumns();
                if (sheet.Cells.Count == 0 && sheet.Pictures.Count == 0)
                    continue;
                if (!sheet.IsVisible)
                    continue;
                //Apply different Image and Print options 
                ImageOrPrintOptions options = new ImageOrPrintOptions();
                //Set Horizontal Resolution
                options.HorizontalResolution = 300;
                //Set Vertical Resolution
                options.VerticalResolution = 300;
                //Set TiffCompression
                options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionCCITT4;
                //Set Autofit options
                options.IsCellAutoFit = false;
                //Set Image Format 
                options.ImageType = ImageType.Tiff;
                //Set printing page type
                options.PrintingPage = PrintingPageType.Default;
                sheet.AutoFitColumns();
                sheet.AutoFitRows();
                //Render the sheet with respect to specified image/print options
                SheetRender sr = new SheetRender(sheet, options);
               
                if (sheet.Pictures.Count >= 1)
                {​​​​​
                    Picture pic = sheet.Pictures[0];
                    pic.FormatPicture.Brightness = 1.0F;
                }​​​​​
              
                if(sr.PageCount  > 0)
                {
                    int pageCount = sr.PageCount;
                    for (int i = 0; i < pageCount; i++)
                    {​​​​​
                        sr.ToImage(i, "e:\\test2\\csvtotif\\outimage" + i + ".tiff");
                        
                    }​​​​​


                }​​​​​

            }

The code generated 107 images to cover all the rows and columns data in the CSV file sheet.

Please try our latest version and in case you still find any issue with latest version, kindly do share a standalone VS.NET console application (runnable) to reproduce the issue. Please exclude Aspose.Cells.Dll to minimize the size of the project. Also, zip and attach your input CSV file. We will check your issue soon.