DefaultTableModel model = (DefaultTableModel) Form.TableDB.getModel(); WritableWorkbook workbook; try { File file = new File ("c:\\output.xls"); workbook = Workbook.createWorkbook(file); WritableSheet sheet = workbook.createSheet("Актион", 0); int i,j; for (i=0;i<model.getColumnCount();i++) { Label label = new Label(i,0, model.getColumnName(i)); sheet.addCell(label); } for (i=0;i<model.getRowCount();i++) { for (j=0;j<model.getColumnCount();j++) { Label label = new Label(j,i+1, (String) model.getValueAt(i,j)); sheet.addCell(label); } } workbook.write(); workbook.close(); Process process = Runtime.getRuntime().exec("cmd /c \"C:\\Program Files\\Microsoft Office\\OFFICE11\\excel.exe\" " + file); process.waitFor(); file.delete(); } catch (IOException e1) { e1.printStackTrace(); } catch (RowsExceededException e1) { e1.printStackTrace(); } catch (WriteException e1) { e1.printStackTrace(); } catch (InterruptedException e1) { e1.printStackTrace(); }
5000 строк экспортирует без вопросов, а вот 17000 нет. Выдает ошибку:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space at jxl.write.biff.File.write(File.java:135) at jxl.write.biff.RowRecord.writeCells(RowRecord.java:323) at jxl.write.biff.SheetWriter.write(SheetWriter.java:479) at jxl.write.biff.WritableSheetImpl.write(WritableSheetImpl.java:1425) at jxl.write.biff.WritableWorkbookImpl.write(WritableWorkbookImpl.java:896) at Aktion$expExcel.actionPerformed(Aktion.java:80) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Где грабли?