简体   繁体   中英

How can I draw a chart with percentages using SmartXLS?

I am trying to draw a chart in an xlsx file using Java. I found SmartXLS and decided to give it a try. So far, I managed to draw the charts correctly, but I can't seem to be able to display percentages on the chart. Any ideas how to do that?

EDIT: I realized my question may not have been detailed enough.

I am trying to draw a Pie chart, where the percentages are added on the chart itself. Thanks to Michael, I know how to do it in cells, but I do not know how to do it on the chart.

EDIT 2: There is no mention of the problem in the SmartXLS documentation, which is why I am requesting help. I do not need anyone writing code for me, just which function can do what I need.

This might be what you are looking for: rangeStyle.setCustomFormat("0.00%");

See: http://www.smartxls.com/java/formatting.htm#vformat-number

In this example , they are applying some formatting to a chart. It seems like it matters from what area you obtain your rangeStyle Object.

For instance, you can call it as rangeStyle = workBook.getRangeStyle(1, 1, 2, 2);//get format from range B2:C3 . The formatting you set applies to selection within the sheet, or the parameters passed to getRangeStyle() (defaults to whole stylesheet without parameters, otherwise a cell range). Perhaps you can select the part of your chart instead of the original datacells, and then apply the formatting as before?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM