@Override protected Transferable createTransferable(SComponent component) { STable table = (STable)component; String htmlText = "<html><body><table>"; String plainText = ""; for(int row:table.getSelectedRows()) { htmlText += "<tr>"; for(int col=0; col<table.getColumnCount(); ++col) { Object object = table.getModel().getValueAt(row, col); htmlText += "<td>" + object.toString() + "</td>"; if(col == (table.getColumnCount()-1)) plainText += object.toString(); else plainText += object.toString() + '\t'; } plainText += "\n"; htmlText += "</tr>"; } htmlText += "</table></body></html>"; return new TextAndHTMLTransferable(plainText, htmlText); }
private void writeColumnWidths(Device device, STable table, int startX, int endX) throws IOException { STableColumnModel columnModel = table.getColumnModel(); // IE-6 crashes if there is a colgroup element but the table body is empty. // That's why, we're writing the colgroup element only if the header is visible OR the model contains at least // one row if (columnModel != null && atLeastOneColumnWidthIsNotNull(columnModel) && (table.isHeaderVisible() || table.getModel().getRowCount() > 0)) { device.print("<colgroup>"); if (isSelectionColumnVisible(table)) writeCol(device, selectionColumnWidth); for (int i = startX; i < endX; ++i) { STableColumn column = columnModel.getColumn(i); if (!column.isHidden()) writeCol(device, column.getWidth()); else ++endX; } device.print("</colgroup>"); Utils.printNewline(device, table); } }