【发布时间】:2019-05-13 20:35:18
【问题描述】:
我需要帮助命令“Ant clean all”。我将尝试构建一个 SAP Hybris 应用程序,但是,一个类将错误返回到行中:
BOLDWEIGHT_BOLD 无法解析或不是字段
有错误的方法:
@Override
public HSSFWorkbook createMDDExportFile(final List<JnJProductModel> products, final String fileName)
{
final String METHOD_NAME = "createMDDExportFile()";
LOGGER.info("JnJGTProductService" + Logging.HYPHEN + METHOD_NAME + Logging.HYPHEN + "Start of the method");
catalogVersionService.setSessionCatalogVersion(Jnjb2bCoreConstants.MDD_CATALOG_ID, Jnjb2bCoreConstants.ONLINE);
final String sheetName = "MDD_Products_Sheet_0";
final HSSFWorkbook excelWorkBook = new HSSFWorkbook();
final HSSFFont font = excelWorkBook.createFont();
ERROR=> font.setBoldweight(Font.BOLDWEIGHT_BOLD);
final HSSFCellStyle style = excelWorkBook.createCellStyle();
style.setFont(font);
final HSSFSheet sheet = excelWorkBook.createSheet(sheetName);
sheet.autoSizeColumn(0);
final HSSFRow downloadDateHeader = sheet.createRow(0);
downloadDateHeader.createCell(0).setCellValue("Download date");
downloadDateHeader.getCell(0).setCellStyle(style);
final String currentTime = new Date().toString();
downloadDateHeader.createCell(1).setCellValue(currentTime);
/*
* final HSSFRow globalAccounHeader = sheet.createRow(1);
* globalAccounHeader.createCell(0).setCellValue("Global Account Name");
* globalAccounHeader.getCell(0).setCellStyle(style);
* globalAccounHeader.createCell(1).setCellValue(currentAccount);
*/
try
{
final String filepath = Config.getParameter(Jnjb2bCoreConstants.EXPORT_EMAIL_ATTACHMENT_PATH_KEY) + File.separator
+ fileName;
createMDDExcelFile(products, sheet, excelWorkBook, style, filepath);
final File file = new File(filepath);
createMedia(file);
}
catch (final Exception exception)
{
LOGGER.error("There was an error while trying to create the excel file for the catalog export", exception);
}
LOGGER.info("JnJGTProductService" + Logging.HYPHEN + METHOD_NAME + Logging.HYPHEN + "End of the method");
return excelWorkBook;
}
【问题讨论】:
-
请分享字体的导入。是图书馆吗?你把图书馆放在哪里了?它是在各自的扩展库文件夹中还是在依赖的扩展库文件夹中?
-
您使用的 POI 库是什么版本的? 1) 确保你已经导入了正确的字体接口包 2) 试试
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD)3) 如果你使用的是新版本的API,那么试试font.setBold(true)doc