Java:
static String dirPath = "C:\a\\Test\\Tes\\";
static String path = "C:\\Test\\ - Kopie.xlsx";
public static void main(String[] args) throws IOException, URISyntaxException {
mergeSheets();
}
static void mergeSheets() throws IOException, URISyntaxException {
List<Sheet> list;
WorkBookClass workBookClass = new WorkBookClass();
final String fileName = "test.xlsx";
String path1 = "C:\\\Test\\Tes\\" + workBookClass.createFile(dirPath, fileName);
FileOutputStream outputStream = new FileOutputStream(path1);
Iterator<Sheet> sheets = workBookClass.inputWorkbook(path);
list = workBookClass.getList(sheets);
Workbook workbookOutput = workBookClass.outputWorkbook();
XSSFSheet outputSheet = (XSSFSheet) workbookOutput.createSheet("Test");
//Create Cell and Row
XSSFCell cell = null;
XSSFRow row = null;
int temp = 0;
workBookClass.setColumnWidth(outputSheet);
int count = 0;
for (int i = 0; i < list.size(); i++) {
count += list.get(i).getPhysicalNumberOfRows();
}
for (int i = 0; i < list.size(); i++) {
for (int k = 0; k <= count; k++) {
row = outputSheet.createRow(k);
for (int j = 0; j < 14; j++) {
cell = row.createCell(j);
if (list.get(0).getRow(k) == null) {
cell.setCellValue("");
} else {
cell.setCellValue(workBookClass.getDataFormatter().formatCellValue(list.get(i).getRow(k).getCell(j)));
}
}
}
}
workbookOutput.write(outputStream);
}
}
Moin,
in einer Datei gibt es mehrere Sheets, ich möchte alle auf einem Blatt schreiben. Kann jemand mir bitte helfen.
Vielen Dank