8000 Fixes: mutiple <definedNames> entries when multiple sheets by rzymek · Pull Request #154 · dhatim/fastexcel · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes: mutiple <definedNames> entries when multiple sheets #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fastexcel-writer/src/main/java/org/dhatim/fastexcel/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ class Font {
* @param underlined Underlined flag.
* @param name Font name. Defaults to "Calibri".
* @param size Font size, in points. Defaults to 11.0.
* @param rgbColor RGB font color. Defaults to "000000".
* @param rgbColor RGB font color. Defaults to "FF000000".
* @return New font object.
*/
static Font build(boolean bold, boolean italic, boolean underlined, String name, BigDecimal size, String rgbColor) {
return new Font(bold, italic, underlined, name == null ? "Calibri" : name, size == null ? BigDecimal.valueOf(11.0) : size, rgbColor == null ? "000000" : rgbColor);
return new Font(bold, italic, underlined, name == null ? "Calibri" : name, size == null ? BigDecimal.valueOf(11.0) : size, rgbColor == null ? "FF000000" : rgbColor);
}

@Override
Expand Down
20 changes: 10 additions & 10 deletions fastexcel-writer/src/main/java/org/dhatim/fastexcel/Workbook.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,19 @@ private void writeWorkbookFile() throws IOException {
/** Defining repeating rows and columns for the print setup...
* This is defined for each sheet separately
* (if there are any repeating rows or cols in the sheet at all) **/


w.append("<definedNames>");
for (Worksheet ws : worksheets) {
int worksheetIndex = getIndex(ws) - 1;
int worksheetIndex = getIndex(ws) - 1;
String defineName = Stream.of(ws.getRepeatingCols(),ws.getRepeatingRows())
.filter(Objects::nonNull)
.map(r -> "&apos;" + ws.getName() + "&apos;!" + r.toString())
.collect(Collectors.joining(","));

w.append("<definedNames>");

if (!defineName.isEmpty()) {
w.append("<definedName function=\"false\" " +
"hidden=\"false\" localSheetId=\"" +
worksheetIndex + "\" name=\"_xlnm.Print_Titles\" " +
w.append("<definedName function=\"false\" " +
"hidden=\"false\" localSheetId=\"" +
worksheetIndex + "\" name=\"_xlnm.Print_Titles\" " +
"vbProcedure=\"false\">")
.append(defineName)
.append("</definedName>");
Expand All @@ -224,8 +224,8 @@ private void writeWorkbookFile() throws IOException {
for (Map.Entry<String, Range> nr : ws.getNamedRanges().entrySet()) {
String rangeName = nr.getKey();
Range range = nr.getValue();
w.append("<definedName function=\"false\" " +
"hidden=\"false\" localSheetId=\"" +
w.append("<definedName function=\"false\" " +
"hidden=\"false\" localSheetId=\"" +
worksheetIndex + "\" name=\"")
.append(rangeName)
.append("\" vbProcedure=\"false\">&apos;")
Expand All @@ -251,8 +251,8 @@ private void writeWorkbookFile() throws IOException {
.append("$" + Range.colToString(af.getRight()) + "$" + (1 + af.getBottom()))
.append("</definedName>");
}
w.append("</definedNames>");
}
w.append("</definedNames>");
w.append("</workbook>");
});
}
Expand Down
0