File tree 2 files changed +26
-2
lines changed
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ public void saveTo(final String path) throws IOException {
145
145
146
146
@ Override
147
147
public EWorkbook with (final ESheet sheet ) {
148
- return new XsWorkbook (this .sheets .with (sheet ));
148
+ return new XsWorkbook (this .sheets .with (sheet ), this . workbook );
149
149
}
150
150
151
151
@ Override
@@ -154,7 +154,7 @@ public EWorkbook with(final Style style) {
154
154
for (final ESheet sheet : this .sheets ) {
155
155
elements .add (sheet .with (style ));
156
156
}
157
- return new XsWorkbook (elements );
157
+ return new XsWorkbook (elements , this . workbook );
158
158
}
159
159
160
160
/**
Original file line number Diff line number Diff line change @@ -86,4 +86,28 @@ public void createsWorkbookWithStyles() throws IOException {
86
86
Matchers .equalTo (IndexedColors .GOLD .getIndex ())
87
87
);
88
88
}
89
+
90
+ /**
91
+ * Creates workbook with multiple sheets.
92
+ * @throws IOException If fails
93
+ */
94
+ @ Test
95
+ public void createsWorkbookWithMultipleSheets () throws IOException {
96
+ final String fsheet = "sheet1" ;
97
+ final String ssheet = "sheet2" ;
98
+ final Workbook wbook = new XsWorkbook ()
99
+ .with (new XsSheet (new XsRow (new TextCell (fsheet ))))
100
+ .with (new XsSheet (new XsRow (new TextCell (ssheet ))))
101
+ .asWorkbook ();
102
+ MatcherAssert .assertThat (
103
+ wbook .getSheetAt (0 ).getRow (1 ).getCell (0 )
104
+ .getStringCellValue (),
105
+ Matchers .equalTo (fsheet )
106
+ );
107
+ MatcherAssert .assertThat (
108
+ wbook .getSheetAt (1 ).getRow (1 ).getCell (0 )
109
+ .getStringCellValue (),
110
+ Matchers .equalTo (ssheet )
111
+ );
112
+ }
89
113
}
You can’t perform that action at this time.
0 commit comments