将 JTable 的特定列导出为 PDF

Export specific columns of JTable to PDF

我想将我的 JTable 内容打印到 PDF 文件中,

我设法做到了,除了现在我想排除第二列并打印其他列,请提供任何有用的指南?

 for (int rows = 0; rows < jTable1.getRowCount(); rows++) {
                for (int cols = 0; cols < jTable1.getColumnCount(); cols++) {
                    PdfPCell cell1 = new PdfPCell(new Phrase(jTable1.getModel().getValueAt(rows,cols).toString(),cellFont));
                    pdfTable.addCell(cell1);
                }
            float[] columnWidths = new float[] {10f,1f,13f,35f,15f,25f,20f,15f,13f,
                    13f,12f,18f,13f,12f,47f,9f,47f};
                    pdfTable.setWidths(columnWidths);

            }

我设法通过将 0f 作为我要隐藏的列的列宽来解决问题![​​=10=]