Hi,
I have a csv-file that I try to convert to XPS. The result looks a bit strange, some characters like “ö,ü” are not correct and the formatting of the coloumns isn’t correct as well. I use the source shown below. May be some settings are missing? Could you please have a look?
If I open the csv in Microsoft Excel and save it as .xlsx-file and try to convert the .xlsx-file to xps, the result looks better. I provide the testfiles in the attached zip.
thank you for your support.
kind regards,
Oliver
string sInFile = “D:\Temp\Test_Aspose.csv”;
string sOutFile = “D:\Temp\Test_Aspose.csv.XPS”;
Aspose.Cells.License cLic = new Aspose.Cells.License();
cLic.SetLicense(“Aspose.Total.lic”);
Workbook workbook = new Workbook(sInFile);
workbook.RemoveMacro();
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.SaveFormat = Aspose.Cells.SaveFormat.XPS;
Aspose.Cells.Rendering.WorkbookRender wr = new Aspose.Cells.Rendering.WorkbookRender(workbook, options);
wr.ToImage(sOutFile);
workbook.Worksheets.Clear();
Hi,
Hi,
Hi,
thanks for your tips, I tried the txtLoadOptions (and used the latest Aspose.cells.dll - 7.3.2.0),
but the result dows not look good yet. The “Empfänger” is not correct, and the columns are cut off.
I attach the result on my side, could you please check again?
Thank you.
kind regards,
Oliver
string sInFile = “D:\Temp\Test_PH.csv”;
string sOutFile = “D:\Temp\Test_PH.csv.xps”;
sInFile = “D:\Temp\Test_Aspose.csv”;
sOutFile = “D:\Temp\Test_Aspose.csv.xps”;
Aspose.Cells.License cLic = new Aspose.Cells.License();
cLic.SetLicense(“Aspose.Total.lic”);
MemoryStream ms = new MemoryStream();
Workbook workbook;
TxtLoadOptions txtLoadOptions = new TxtLoadOptions();
txtLoadOptions.Separator = ‘;’;
workbook = new Workbook(sInFile, txtLoadOptions);
workbook.RemoveMacro();
Aspose.Cells.Rendering.ImageOrPrintOptions saveOptionsCell = new Aspose.Cells.Rendering.ImageOrPrintOptions();
saveOptionsCell.SaveFormat = Aspose.Cells.SaveFormat.XPS;
workbook.Save(sOutFile, Aspose.Cells.SaveFormat.XPS);
workbook.Worksheets.Clear();
Hi,
Hi,
Thanks for using Aspose.Cells.
We have investigated your issue and found out that your issue is occurring because of Encoding. Please set the encoding option using TxtLoadOptions.Encoding property and it will resolve your issue.
Please see the following complete code. I have also attached the output xps and screenshot for your reference
C#
string filePath = @“F:\Shak-Data-RW\Downloads\Test_Aspose.csv”;
MemoryStream ms = new MemoryStream();
Workbook workbook;
TxtLoadOptions txtLoadOptions = new TxtLoadOptions();
txtLoadOptions.Encoding = Encoding.GetEncoding(“ISO-8859-1”);
txtLoadOptions.Separator = ‘;’;
workbook = new Workbook(filePath, txtLoadOptions);
workbook.RemoveMacro();
Aspose.Cells.Rendering.ImageOrPrintOptions saveOptionsCell = new Aspose.Cells.Rendering.ImageOrPrintOptions();
saveOptionsCell.SaveFormat = Aspose.Cells.SaveFormat.XPS;
workbook.Save(filePath + “.out.xps”, Aspose.Cells.SaveFormat.XPS);
workbook.Worksheets.Clear();
Screenshot:
Hi Shakeel,
thank you for your help. Yes, the encoding solvels the problem with the wrong characters.
Is there a chance to improve the layout? Some columns are cut-off. Is there a setting that controls the column-width?
best regards,
Oliver
Hi Oliver,
yes, that is right, this is another improvement. Thank you.
The only problem, that remains, is, that the lines 2…n are not under the corresponding header in line 1. Is there a chance to fix that?
Thank you for your excellent support.
kind regards,
Oliver
Hi,
Hi Amjad,
ok, this looks quit good now, I think this is the best I can get for those csv files.
Thank you all very much for your support and patience.
kind regards,
Oliver
Hi Oliver,