Search in sources :

Example 6 with ExcelColDVO

use of com.kyj.fx.voeditor.visual.excels.base.ExcelColDVO in project Gargoyle by callakrsos.

the class ExcelUtil method createExcel.

/**
	 * 2014. 10. 3. KYJ
	 *
	 * @param createJtable
	 * @return
	 * @throws Exception
	 * @처리내용 : JTable의 데이터를 이용하여 엑셀파일을 생성한다.
	 */
public static boolean createExcel(JTable createJtable, String makeFile) throws Exception {
    int rowCount = createJtable.getRowCount();
    int columnCount = createJtable.getColumnCount();
    TableModel model = createJtable.getModel();
    ExcelSVO svo = new ExcelSVO();
    TableColumnModel columnModel = createJtable.getColumnModel();
    ArrayList<ExcelColDVO> arrayList = new ArrayList<ExcelColDVO>();
    for (int j = 0; j < columnCount; j++) {
        TableColumn column = columnModel.getColumn(j);
        Object headerValue = column.getHeaderValue();
        arrayList.add(new ExcelColDVO(j, (String) headerValue));
    }
    for (int i = 0; i < rowCount; i++) {
        for (int j = 0; j < columnCount; j++) {
            Object valueAt = model.getValueAt(i, j);
            svo.setColDvoList("sheet1", arrayList);
            svo.addSheetExcelDVO("sheet1", new ExcelDataDVO(i, j, valueAt));
        }
    }
    createExcel(makeFile, svo);
    return false;
}
Also used : ExcelDataDVO(com.kyj.fx.voeditor.visual.excels.base.ExcelDataDVO) ExcelColDVO(com.kyj.fx.voeditor.visual.excels.base.ExcelColDVO) ArrayList(java.util.ArrayList) TableColumnModel(javax.swing.table.TableColumnModel) ExcelSVO(com.kyj.fx.voeditor.visual.excels.base.ExcelSVO) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) TableColumn(javax.swing.table.TableColumn) TableModel(javax.swing.table.TableModel)

Aggregations

ExcelColDVO (com.kyj.fx.voeditor.visual.excels.base.ExcelColDVO)6 ArrayList (java.util.ArrayList)5 ExcelDataDVO (com.kyj.fx.voeditor.visual.excels.base.ExcelDataDVO)4 ExcelSVO (com.kyj.fx.voeditor.visual.excels.base.ExcelSVO)3 Cell (org.apache.poi.ss.usermodel.Cell)3 Sheet (org.apache.poi.ss.usermodel.Sheet)3 Row (org.apache.poi.ss.usermodel.Row)2 Workbook (org.apache.poi.ss.usermodel.Workbook)2 XSSFRichTextString (org.apache.poi.xssf.usermodel.XSSFRichTextString)2 File (java.io.File)1 DecimalFormat (java.text.DecimalFormat)1 Date (java.util.Date)1 List (java.util.List)1 TableColumn (javax.swing.table.TableColumn)1 TableColumnModel (javax.swing.table.TableColumnModel)1 TableModel (javax.swing.table.TableModel)1 TableModelDVO (kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)1 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)1 HSSFColor (org.apache.poi.hssf.util.HSSFColor)1 CellDateFormatter (org.apache.poi.ss.format.CellDateFormatter)1