ASF Bugzilla – Attachment 36429 Details for
Bug 63152
Too many identical CellStyles cause .xls to be incorrectly rendered in Office 365
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
A test case to reproduce the issue
Issue.java (text/plain), 1.70 KB, created by
Anthony V
on 2019-02-07 10:01:48 UTC
(
hide
)
Description:
A test case to reproduce the issue
Filename:
MIME Type:
Creator:
Anthony V
Created:
2019-02-07 10:01:48 UTC
Size:
1.70 KB
patch
obsolete
>import java.io.IOException; >import java.io.OutputStream; >import java.nio.file.Files; >import java.nio.file.Path; > >import org.apache.poi.hssf.usermodel.HSSFOptimiser; >import org.apache.poi.hssf.usermodel.HSSFWorkbook; >import org.apache.poi.ss.usermodel.Cell; >import org.apache.poi.ss.usermodel.CellStyle; >import org.apache.poi.ss.usermodel.Row; >import org.apache.poi.ss.usermodel.Sheet; >import org.apache.poi.ss.usermodel.Workbook; >import org.apache.poi.ss.util.CellReference; > >import static org.apache.poi.ss.usermodel.BorderStyle.THIN; > >public class Issue { > > public static void main(String[] args) throws IOException { > try (OutputStream out = Files.newOutputStream(Path.of("report.xls"))) { > new Issue().generateReport().write(out); > } > } > > public Workbook generateReport() { > HSSFWorkbook wb = new HSSFWorkbook(); > Sheet sheet = wb.createSheet("styles"); > > for (int i = 0; i < 4; i++) { > Row row = sheet.createRow(i); > for (int j = 0; j < 11; j++) { > Cell cell = row.createCell(j); > cell.setCellStyle(createDefaultStyle(wb)); > cell.setCellValue(CellReference.convertNumToColString(j) + (i + 1)); > } > } > > // workaround 1 >// HSSFOptimiser.optimiseCellStyles(wb); > return wb; > } > > private CellStyle createDefaultStyle(Workbook wb) { > CellStyle style = wb.createCellStyle(); > style.setBorderTop(THIN); > style.setBorderBottom(THIN); > style.setBorderLeft(THIN); > style.setBorderRight(THIN); > > // workaround 2 >// style.setFont(wb.createFont()); > return style; > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 63152
: 36429 |
36766