我正在使用pdfbox的boxable制作pdf格式的表格。它工作得很好。只有一件事,我需要改变标题颜色和单元格样式。
我正在使用下面的代码。请给出建议
List<List> data = new ArrayList();
data.add(new ArrayList<>(Arrays.asList("Column One", "Column Two", "Column Three", "Column Four", "Column Five")));
for (int i = 1; i <= 100; i++)
{
data.add(new ArrayList<>(Arrays.asList("Row " + i + " Col One", "Row " + i + " Col Two", "Row " + i + " Col Three", "Row " + i + " Col Four", "Row " + i + " Col Five")));
BaseTable dataTable = new BaseTable(yStart, yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true, true);
DataTable t = new DataTable(dataTable, page);
t.addListToTable(data, DataTable.HASHEADER);
dataTable.draw();
}发布于 2021-04-09 23:37:49
t.getDataCellTemplateEven().setFillColor(Color.WHITE);
t.getDataCellTemplateOdd().setFillColor(Color.WHITE);
t.getHeaderCellTemplate().setFillColor(Color.WHITE);其中t是DataTable类的对象。Color类是AWT类,您可以随意更改它。所以不需要编辑库。
发布于 2017-04-24 01:49:55
我在可装箱代码中更改了table.java中的代码。
如下图所示
PDStreamUtils.rect(tableContentStream,margin,yStart,width,headerBottomMargin,Color.GRAY);
https://stackoverflow.com/questions/43369624
复制相似问题