怎么往同一个cell里放入大小不一致的文字,比如: 金额(单位:万元)单位:万元要比金额小一些
请参阅以下示例代码,了解如何设置单元格中选定文本或字符的格式,以供参考。请参考代码段并根据您的需要编写自己的代码来完成您的任务。
// Instantiating a Workbook object
Workbook workbook = new Workbook();
//Get the first (default) worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Adding some value to the "A1" cell
Cell cell = cells.get("A1");
cell.setValue("Amount (unit: 10,000 yuan)");
//Get the selected text font object
com.aspose.cells.Font font = cell.characters(7, 18).getFont();
// Setting the font name and size of selected characters
font.setName("Arial Black");
font.setSize(8);
// Setting the font color of selected characters to blue
font.setColor(com.aspose.cells.Color.getBlue());
// Saving the Excel file
workbook.save("d:\\files\\out1.xlsx");
out1.zip (6.1 KB)
请参阅附件中的输出文件以供参考。另外,请参阅有关如何格式化或更改所选字符的字体的文档以供参考。
https://docs.aspose.com/cells/java/data-formatting/#formatting-selected-characters-in-a-cell