[1379] 견적서 출력 zip, address, tel, fax 수정 #386
@ -1869,6 +1869,9 @@ public class EstimateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyExcelNumberFormat(workbook);
|
applyExcelNumberFormat(workbook);
|
||||||
|
applyExcelFixedNumberFormat(workbook, Arrays.asList("H25", "C12"), "#,##0.00");
|
||||||
|
applyExcelFixedNumberFormat(workbook, Arrays.asList("I2"), "#,##0.00\" kW\"");
|
||||||
|
applyExcelFixedNumberFormat(workbook, Arrays.asList("X32", "I44"), "#,##0.00");
|
||||||
|
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
workbook.write(byteArrayOutputStream);
|
workbook.write(byteArrayOutputStream);
|
||||||
@ -2040,6 +2043,10 @@ public class EstimateService {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
String normalized = raw.replace(",", "");
|
String normalized = raw.replace(",", "");
|
||||||
|
String upper = normalized.toUpperCase(Locale.ROOT);
|
||||||
|
if (upper.endsWith("KW")) {
|
||||||
|
normalized = normalized.substring(0, normalized.length() - 2).trim();
|
||||||
|
}
|
||||||
if (!normalized.matches("[-+]?\\d+(\\.\\d+)?")) {
|
if (!normalized.matches("[-+]?\\d+(\\.\\d+)?")) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -2122,6 +2129,88 @@ public class EstimateService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void applyExcelFixedNumberFormat(Workbook workbook, List<String> cellRefs,
|
||||||
|
String formatString) {
|
||||||
|
if (workbook == null || cellRefs == null || formatString == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataFormat dataFormat = workbook.createDataFormat();
|
||||||
|
short numberFormat = dataFormat.getFormat(formatString);
|
||||||
|
Map<Short, CellStyle> styleCache = new HashMap<>();
|
||||||
|
|
||||||
|
for (int s = 0; s < workbook.getNumberOfSheets(); s++) {
|
||||||
|
Sheet sheet = workbook.getSheetAt(s);
|
||||||
|
if (sheet == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (String ref : cellRefs) {
|
||||||
|
int[] rc = parseCellRef(ref);
|
||||||
|
if (rc == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Row row = sheet.getRow(rc[0]);
|
||||||
|
if (row == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Cell cell = row.getCell(rc[1]);
|
||||||
|
if (cell == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CellType cellType = cell.getCellType();
|
||||||
|
if (cellType == CellType.STRING) {
|
||||||
|
Object parsed = parseExcelNumber(cell.getStringCellValue());
|
||||||
|
if (parsed instanceof Number) {
|
||||||
|
cell.setCellValue(((Number) parsed).doubleValue());
|
||||||
|
cellType = CellType.NUMERIC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cellType != CellType.NUMERIC) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CellStyle style = cell.getCellStyle();
|
||||||
|
if (style == null) {
|
||||||
|
style = workbook.createCellStyle();
|
||||||
|
}
|
||||||
|
short styleIdx = style.getIndex();
|
||||||
|
CellStyle cached = styleCache.get(styleIdx);
|
||||||
|
if (cached == null) {
|
||||||
|
CellStyle newStyle = workbook.createCellStyle();
|
||||||
|
newStyle.cloneStyleFrom(style);
|
||||||
|
newStyle.setDataFormat(numberFormat);
|
||||||
|
styleCache.put(styleIdx, newStyle);
|
||||||
|
cached = newStyle;
|
||||||
|
}
|
||||||
|
cell.setCellStyle(cached);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int[] parseCellRef(String ref) {
|
||||||
|
if (ref == null || ref.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
int col = 0;
|
||||||
|
while (i < ref.length()) {
|
||||||
|
char c = ref.charAt(i);
|
||||||
|
if (c < 'A' || c > 'Z') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
col = col * 26 + (c - 'A' + 1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (i == 0 || i >= ref.length()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int row;
|
||||||
|
try {
|
||||||
|
row = Integer.parseInt(ref.substring(i));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new int[] {row - 1, col - 1};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QSP Q.CAST 견적서 전송 API
|
* QSP Q.CAST 견적서 전송 API
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user