위택스 엑셀파일 업로드 후 다운로드받을 때 셀 서식을 텍스트형식으로 설정

main
이범준 2 weeks ago
parent 05d2182059
commit 8be4978348

@ -241,6 +241,10 @@ public class Rent04Controller extends ApplicationController {
ModelAndView mav = new ModelAndView("downloadView"); ModelAndView mav = new ModelAndView("downloadView");
XLSWriter xlsx = new XLSWriter().worksheet(0); XLSWriter xlsx = new XLSWriter().worksheet(0);
CellStyle unformattedText = xlsx.workbook().createCellStyle();
short short_text = xlsx.workbook().createDataFormat().getFormat("@");
unformattedText.setDataFormat(short_text);
List<CellDef> cellDefs = new ArrayList<CellDef>(); List<CellDef> cellDefs = new ArrayList<CellDef>();
cellDefs.add(new CellDef().setField("A").setLabel("관리번호")); cellDefs.add(new CellDef().setField("A").setLabel("관리번호"));
cellDefs.add(new CellDef().setField("B").setLabel("전자납부번호")); cellDefs.add(new CellDef().setField("B").setLabel("전자납부번호"));
@ -259,6 +263,12 @@ public class Rent04Controller extends ApplicationController {
cellDefs.add(new CellDef().setField("O").setLabel("변경자 상세주소")); cellDefs.add(new CellDef().setField("O").setLabel("변경자 상세주소"));
cellDefs.add(new CellDef().setField("P").setLabel("변경자 우편번호")); cellDefs.add(new CellDef().setField("P").setLabel("변경자 우편번호"));
Map<String,Object> valueMap = new HashMap<String,Object>();
for(CellDef def : cellDefs) {
valueMap.put(def.getLabel(), unformattedText);
}
CellDef.setValues(cellDefs, valueMap);
List<DataObject> list = fromJson(query.getCellDataDef(), new TypeReference<List<DataObject>>(){}); List<DataObject> list = fromJson(query.getCellDataDef(), new TypeReference<List<DataObject>>(){});
xlsx.cell(0, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx))); xlsx.cell(0, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx)));

Loading…
Cancel
Save