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;
}
Aggregations