excel转PDF时,字体加粗了

excel 文件里面有的行包含特殊的字符,转PDF时自动加粗了,导致与其他行格式不一致

@SeanXie

  • 转换时使用的 Aspose.Cells 版本是什么?
  • Excel 文件中使用的特殊字符具体是什么字符?是否为 Unicode 特殊符号或字体特定字符?
  • 这些字符在 Excel 中原本未加粗,转换后 PDF 中才变加粗,还是原始 Excel 中已存在格式差异?
  • 是否设置了 PDF 转换时的字体嵌入或替换选项?例如 PdfSaveOptions.FontSubstitution
  • 该问题是否在所有字体下都会出现,还是仅在使用特定字体(如中文字体、Symbol 等)时发生?
  • 是否可以提供最小可复现文件片段或代码示例,以便验证问题?

@SeanXie
请上传你的模板文件, 我们会尽快检查?
请确认设置的字体是否能够显示该特殊字符,以及字体文件是否在服务器中正确安装。

问题:Excel 单元格设置的是Arial,不支持特殊字符,所以代码修改成了单元格字体 Arial Unicode MS(如下),服务器上也安装这个字体了,但是PDF渲染时有特殊字符的文案还是加粗了,
image.png (31.4 KB)

// 重置字体为 Arial Unicode MS 以支持特殊字符显示
com.aspose.cells.Font font = style.getFont();
if(font != null && “Arial”.equals(font.getName())){
font.setName(“Arial Unicode MS”);
cell.setStyle(style, true); // 使用强制更新参数
logger.info(“重置字体: {}, value:{}”, font.getName(), cell.getValue());
}
导出订单-主配产品多行展示示意模板.xlsx (4).xlsx.zip (13.4 KB)

@SeanXie ,

我们已经复现此问题,更改单元格字体,未能生效。我们将建单跟踪此问题。
目前可以用如下代码更新字体:

Workbook wb = new Workbook("导出订单-主配产品多行展示示意模板.xlsx (4).xlsx");
System.out.println(wb.getDefaultStyle().getFont());

Cells cells = wb.getWorksheets().get(0).getCells();
Cell d15 = cells.get("D15");
Style style = d15.getStyle();
style.getFont().setName("Arial Unicode MS");
d15.setStyle(style);

FontSetting[] fontSettings = d15.getCharacters();
for(FontSetting fontsetting : fontSettings)
{
    fontsetting.getFont().setName("Arial Unicode MS");
}
d15.setCharacters(fontSettings);

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

wb.save(TMP_DIR + "output_Java.pdf", pdfSaveOptions);

@SeanXie
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-59628

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

按照你们的方式修改还是不可以,有特殊字符的内容还是被渲染加粗了
// 重置字体为
Arial Unicode MS 以支持中文显示
com.aspose.cells.Font font = style.getFont();
if(font != null && “Arial”.equals(font.getName())){
font.setName(“Arial Unicode MS”);
cell.setStyle(style, true); // 使用强制更新参数
FontSetting[] fontSettings = cell.getCharacters();
for(FontSetting fontsetting : fontSettings)
{
fontsetting.getFont().setName(“Arial Unicode MS”);
}
cell.setCharacters(fontSettings);
logger.info(“重置字体: {}, value:{}”, font.getName(), cell.getValue());
}

@SeanXie ,

请分享生成的pdf文件,以便于我们分析。
另外,你可以在Excel中尝试把字体改为"Arial Unicode MS", 再手动保存为pdf。比较一下字体粗细的差别。

@SeanXie,

我们很高兴地通知您,您所报告的问题(工单编号:“CELLSNET-59632”)已成功解决。之前在更改单元格字体后,内部富文本字体未更新的错误已被修复。此改进将包含在我们即将发布的 Aspose.Cells v26.1 版本中,预计将在 2026 年 1 月上半月发布(可能是下周)。一旦新版本可用,您将收到通知。

The issues you have found earlier (filed as CELLSNET-59628) have been fixed in this update. This message was posted using Bugs notification tool by leoluo