Table cells text problem

Hello,
I have several problems with aspose.cells. My java code dynamically creates and populates tables with information in excel and then saved as pdf. I am working with multiple languages so tables are populated with many kinds of characters from different languages. Problem is that these characters are not printed correctly: Letters is printed on top of one another (see attached image: lettersProblem.jpg). I marked errors with red circles in this example (In this case is German letters which causing problems. I haven’t tried with different languages yet) .

Second issue is with text in cells. For some reason some spaces in text is cut off. For example “Region:01 District:H” would be printed as “Region:01District:H” with gap between ‘01’ and ‘Distinct’ missing. And also some of the text is cut off in the cell even if I set cell.getStyle().setShrinkToFit(true) ) . I attached screenshot: TextCutOff.jpg where I marked errors with red circles.


This is code which inserts text into the cell:


cell.setValue(headerCellText);
Style cellStyle = cell.getStyle();
cellStyle.getFont().setBold(true);
cellStyle.setForegroundColor(headerColor);
cellStyle.setPattern(BackgroundType.SOLID);
cellStyle.setShrinkToFit(true);

// aligh text
String align = headerCell.getString("align");
if (align.equals("center")) {
cellStyle.setHorizontalAlignment(TextAlignmentType.CENTER);
} else if (align.equals("right")) {
cellStyle.setHorizontalAlignment(TextAlignmentType.RIGHT);
}
cell.setStyle(cellStyle);

Hi,


Please try our latest fix/version: Aspose.Cells for Java v7.5.0.2

Well, if you save to Excel file dynamically, is the file fine with your mentioned issues or you find the two issues you mentioned. If this is the case, kindly save to Excel file and provide it here, we will check your issue by converting your provided Excel file to PDF format if we could find the issue. Also, kindly make sure that all the fonts used in the Excel file are properly installed on your system before Excel to PDF conversion, e.g you may try to add a line of code at the start to set the font directory accordingly:

CellsHelper.setFontDir(“c:\windows\fonts”); //change the path to your font directory for Windows OS.
In case of Linux, use the directory path according to Linux syntax. e.g
CellsHelper.setFontDir(“/home/usr/test/winfont”);

Let us know if it makes any difference.

Thank you.

Problems I mentioned earlier don’t occur when I save file as .xlsm but only if I save file as PDF using aspose.cells. I tried to save file as .xlsm and then convert it to PDF using Microsoft Excel but generated PDF was just fine and didn’t have any problems. So I assume that problem is in aspose when saving as PDF. I attached file chart.xlsm. Please could you load this file into Workbook and try to save it as PDF and you will see all the issues I mentioned before. I also attached Aspose generated PDF if you need it (chart.pdf). Thank you very much.

Kind Regards

Alikas

Hi,

Thanks for your posting and using Aspose.Cells for Java.

We have tested your issue with the latest version: Aspose.Cells
for Java v7.5.0.2
and found it is working fine.

We have attached the output pdf file generated by the following code and it shows no error.

Java


String filePath=“F:\Shak-Data-RW\Downloads\chart.xlsm”;


Workbook workbook = new Workbook(filePath);

workbook.save(filePath + “.out.pdf”,SaveFormat.PDF);


Hi,
I also use aspose-cells-7.5.0.2.jar and JRE7 but I don’t know why I don’t get result you get. This is code I use to convert xlsm to pdf:

public static void main(String[] args) throws Exception {
Workbook wb = new Workbook("C:\\ chart.xlsm");

wb.save("C:\\ chart.pdf", SaveFormat.PDF);

System.out.println("Coverted!!!! " + new Date());
}

I attached input (chart.xlsm: different then I sent previously) and output (chart.xlsm).
I also attached screenshot with marked errors and explanations (textErrors.jpg).
Can you please try to use same file (chart.xlsm) to convert to pdf again.
Can you please tell me what I am doing wrong here.

Thank you.
Kind Regards
Alikas

Hello,

Problem was with fonts Aspose.Cells was using. Seems like problems caused was something to do with my computer configurations(Windows 7) because that I tried same thing on different machine and everything was just fine.

I fixed my problem this way:

CellsHelper.setFontDir(“C:\WINDOWS\Fonts”);

After that everything run as expected.

Do you know why Aspose was picking up corrupted fonts in first place on my machine?

Kind Regards

Alikas

Hi,

Thanks for your posting and using Aspose.Cells for Java.

It is good to know you were able to sort out your problem. It is strange why Aspose was picking up corrupted fonts in first place. Probably, your machine had missing fonts that were causing you this problem.

If you encounter any other issue, please feel free to post on our forums, we will be glad to help you further.