use of com.kyj.fx.voeditor.visual.excels.base.ExcelDataDVO 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;
}
use of com.kyj.fx.voeditor.visual.excels.base.ExcelDataDVO in project Gargoyle by callakrsos.
the class VoWizardUtil method createExcelFile.
/**
* 엑셀파일생성
*
* @param pathDir
* @param _fileName
* @param models
* @return 생성된 엑셀파일에 대한 파일 객체
* @throws GargoyleFileAlreadyExistException
*/
public static File createExcelFile(File pathDir, String _fileName, List<TableModelDVO> models, boolean isOverWrite) throws GargoyleFileAlreadyExistException {
File saveFile = null;
if (!pathDir.exists() || !pathDir.isDirectory())
return saveFile;
String fileName = _fileName;
String createFilePathName = pathDir.getAbsolutePath() + File.separator + fileName;
if (!_fileName.endsWith(".xlsx")) {
createFilePathName.concat(".xlsx");
}
saveFile = new File(createFilePathName);
if (saveFile.exists() && !isOverWrite) {
throw new GargoyleFileAlreadyExistException("already exists. file");
}
// 로우번호 채번링
AtomicInteger atomicInteger = new AtomicInteger(2);
List<ExcelDataDVO> collect = models.stream().map(vo -> {
List<ExcelDataDVO> list = new ArrayList<ExcelDataDVO>();
String columnName = vo.getDatabaseColumnName();
String dataType = vo.getType();
String dataSize = vo.getSize();
String desc = vo.getDesc();
int row = atomicInteger.getAndIncrement();
list.add(new ExcelDataDVO(row, 0, ValueUtil.toCamelCase(ValueUtil.decode(columnName, columnName, vo.getName()).toString())));
list.add(new ExcelDataDVO(row, 1, dataType));
list.add(new ExcelDataDVO(row, 2, dataSize));
list.add(new ExcelDataDVO(row, 3, desc));
return list;
}).collect(() -> {
/* 컬럼헤더처리 */
ArrayList<ExcelDataDVO> arrayList = new ArrayList<ExcelDataDVO>();
arrayList.add(new ExcelDataDVO(1, 0, VoWizardUtil.COLUMN_NAME, /* "컬럼명" */
Color.GREEN));
arrayList.add(new ExcelDataDVO(1, 1, VoWizardUtil.TYPE, /* "데이터타입" */
Color.GREEN));
arrayList.add(new ExcelDataDVO(1, 2, VoWizardUtil.DATA_LENGTH, /* "데이터사이즈" */
Color.GREEN));
arrayList.add(new ExcelDataDVO(1, 3, VoWizardUtil.COMMENTS, /* "설명" */
Color.GREEN));
return arrayList;
}, (t, u) -> t.addAll(u), (t, u) -> t.addAll(u));
ExcelSVO svo = new ExcelSVO();
svo.addSheetExcelDVO(SHEET_NAME, collect);
try {
ExcelUtil.createExcel(saveFile.getAbsolutePath(), svo, false);
} catch (Exception e1) {
ValueUtil.toString(e1);
saveFile = null;
}
return saveFile;
}
Aggregations