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

Free Support Forum - aspose.com

CSV to Tiff conversion

Why conversion can’t recognize the Separator automatically. I have to specify the separator if it is “;” .
Second My CSV file is ANSI Encoding but I has special Danish char So I am setting LoadOptions.Encoding = UTF8 but this not impacting the output.

I want UTF 8 encoding for each conversion so that it can manage the special char irrespective to what is the original file encoding…
Second it should automatically detect the separator. Is there any option by which i can enable this.99.zip (284 Bytes)

Here is my code and ZIP file
Aspose.Cells.TxtLoadOptions loadOptions = new Aspose.Cells.TxtLoadOptions(Aspose.Cells.LoadFormat.Csv);
loadOptions.Separator = ‘;’;
using (Aspose.Cells.Workbook book = new Aspose.Cells.Workbook(fileDetail.FileInfo.FullName, loadOptions))
{
Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
imgOptions.OnePagePerSheet = true;
imgOptions.HorizontalResolution = 300;
imgOptions.VerticalResolution = 300;
imgOptions.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionLZW;
imgOptions.TiffColorDepth = Aspose.Cells.Rendering.ColorDepth.Format8bpp;
imgOptions.ImageType = Aspose.Cells.Drawing.ImageType.Tiff;
Aspose.Cells.Rendering.WorkbookRender wr = new Aspose.Cells.Rendering.WorkbookRender(book, imgOptions);
wr.ToImage(fileDetail.OutputPath);
}

@atyagi39,

Please note, a CSV file is just a plain text file and one can use any way to have separator and any encoding type to create it. It might not be possible to give a solution to handle all kinds of template files. You got to set the separator and may specify the encoding type for your files by TxtLoadOptions.Encoding. Otherwise the used encoding completely depends on the System, just like you create a StreamReader from a Stream without specifying the encoding.

Hope, this helps a bit.

I do agree with you but Setting up Encoding in Loadoption not working.
Attach file is Ansi encoding and if you will convert it you will see question mark in place of special character.
loadOptions.Encoding= Encoding.UTF8
I 99.zip (273 Bytes)

@atyagi39,

Setting up UTF encoding won’t show the character properly either. You need to set proper encoding type to show the special chars. I tried the following sample code with proper encoding type and it shows the special character fine in the output TIFF image:
e.g.
Sample code:

Aspose.Cells.TxtLoadOptions loadOptions = new Aspose.Cells.TxtLoadOptions(Aspose.Cells.LoadFormat.Csv);
loadOptions.Separator = ';';
loadOptions.Encoding = System.Text.Encoding.GetEncoding(0x4e4);
//Or
//loadOptions.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");//this works too.
//Or    
//loadOptions.Encoding = System.Text.Encoding.Default;//this also works on my end.
using (Aspose.Cells.Workbook book = new Aspose.Cells.Workbook("e:\\test2\\99.csv", loadOptions))
{
     Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
     imgOptions.OnePagePerSheet = true;
     imgOptions.HorizontalResolution = 300;
     imgOptions.VerticalResolution = 300;
     imgOptions.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionLZW;
     imgOptions.TiffColorDepth = Aspose.Cells.Rendering.ColorDepth.Format8bpp;
     imgOptions.ImageType = Aspose.Cells.Drawing.ImageType.Tiff;
     Aspose.Cells.Rendering.WorkbookRender wr = new Aspose.Cells.Rendering.WorkbookRender(book, imgOptions);
     wr.ToImage("e:\\test2\\out1.tiff");
} 

Hope, this helps a bit.

Thanks this is working.

@atyagi39,

Good to know that your issue is fixed by following the suggested code segment. In the event of further queries or issue, feel free to write us back.