Problem inserting text into cell

Hi there

I encounter a programming problem about Aspose.Cell. At this test, I want to insert a image created by Aspose Cell into a word file. Everything is all right except the the code in red.

Is there any way to set the charset for the cell, or solve the problem?

Thanks for help.

There are part of my codes:

Chart chart = null;

Workbook workbook = new Workbook();

workbook.getWorkbookSettings().setLanguage(CountryCode.CHINA);

Worksheet sheet = workbook.getWorksheets().getSheet(0);

sheet.setName(“Data”);

chart = sheet.getCharts().addChart(ChartType.COLUMN_CLUSTERED, 1, 1, 20, 10);

Cells cells = sheet.getCells();

int[][] array = {

{2011, 555, 869},

{2012, 286, 565}

};

cells.importArray(array, 0, 0);

cells.getCell(2, 1).setValue(" 北京 ");

cells.getCell(2, 2).setValue(" 郑州 ");

System.out.println(cells.getCell(2,1).getValue()); // it will display " 北京 "

chart.getNSeries().add(“Data!B1:C2”, true);

chart.getNSeries().setCategoryData(“Data!A1:A2”);

for (int i = 0; i < chart.getNSeries().size(); i++){

chart.getNSeries().get(i).setName(cells.getCell(2, i + 1).getValue().toString());

}

ByteArrayOutputStream out = new ByteArrayOutputStream();

chart.toImage(out, new ImageOptions());

byte[] data = out.toByteArray();

BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));

builder.moveToBookmark(“COLUMN”);

builder.insertImage(image);


This message was posted using Email2Forum by aske012.

Hi,


Thanks for sharing the details and sample code.

It looks like an issue with the product regarding the Chinese text. I have logged a ticket with an id “CELLSNET-41353” for your issue. We will look into your issue soon.

Thank you.

Thanks for your reply.


yes, I find that we can set the charset by SaveOptions parameter of the SAVE() method, but I don’t find a encoding way when set the cell value.

Is there anything I missed?

Please DO tell me when there is a solution.

Hi,


We will look into your issue in the next week and try to figure it out.
Please spare us little time.

Once we have any update on it, we will share it here immediately.

Thank you.

Hi,

We have looked into your issue a bit. By default, the generated Excel file use “Arial” as the default font. The Chinese text cannot display using “Arial” font. So you may change the default font of the workbook by using the following code:
e.g.

Style defaultStyle = workbook.getDefaultStyle();

defaultStyle.getFont().setName("Simsun");

workbook.setDefaultStyle(defaultStyle);

Thank you.

Thanks.


But I don’t find workbook.setDefaultStyle(defaultStyle) method in the lastest Aspose Word Demo using its own aspose-cell.jar.

Now I will update aspose cell to the lastest version, hoping the problem will be solved.

Thanks.


By updating aspose cell to version 7.3.5 and some code adjustments, It finally displays properly.

Hi,


Good to know that it finally works for you.

Feel fee to contact us any time if you need further help or have some other queries/issues.

We will be happy to assist you .

thank you.