Search in sources :

Example 6 with ExcelSVO

use of com.kyj.fx.voeditor.visual.excels.base.ExcelSVO 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

ExcelDataDVO (com.kyj.fx.voeditor.visual.excels.base.ExcelDataDVO)6 ExcelSVO (com.kyj.fx.voeditor.visual.excels.base.ExcelSVO)6 ArrayList (java.util.ArrayList)5 ExcelColDVO (com.kyj.fx.voeditor.visual.excels.base.ExcelColDVO)3 File (java.io.File)3 List (java.util.List)2 TableModelDVO (kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)2 Cell (org.apache.poi.ss.usermodel.Cell)2 Row (org.apache.poi.ss.usermodel.Row)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 Test (org.junit.Test)2 VoEditor (com.kyj.fx.voeditor.core.VoEditor)1 ClassMeta (com.kyj.fx.voeditor.core.model.meta.ClassMeta)1 GargoyleFileAlreadyExistException (com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException)1 DatabaseTypeMappingFunction (com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction)1 Color (java.awt.Color)1 SQLException (java.sql.SQLException)1 DecimalFormat (java.text.DecimalFormat)1 Date (java.util.Date)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1