Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void write(String PATH) {
- try {
- InputStream inp = new FileInputStream(PATH + "\workbook.xlsx");
- Workbook wb = null;
- try {
- wb = WorkbookFactory.create(inp);
- } catch (EncryptedDocumentException | InvalidFormatException e) {
- e.printStackTrace();
- }
- Sheet sheet = wb.getSheetAt(1);
- int rowCounter = 0;
- Cell[] mas = new Cell[500];
- List<Cell> cellList = new LinkedList<Cell>();
- for (int i = 0; i < getFinishFile().size(); i++) {
- Row row = sheet.createRow(rowCounter++);
- for (int j = 0; i < mas.length; i++) {
- mas[i] = row.createCell(j);
- cellList.add(mas[i]);
- }
- int j = 0;
- for (Cell c : cellList) {
- c.setCellValue(getFinishFile().get(i)[j]);
- j++;
- }
- }
- FileOutputStream fileOut = new FileOutputStream(PATH + "\workbook.xlsx");
- wb.write(fileOut);
- fileOut.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- private static final LENGTH = 500
- private void write(String PATH) {
- try {
- InputStream inp = new FileInputStream(PATH + "\workbook.xlsx");
- Workbook wb = WorkbookFactory.create(inp);
- Sheet sheet = wb.getSheetAt(1);
- for (int i = 0; i < getFinishFile().size(); i++) {
- Row row = sheet.createRow(i);
- for (int j = 0; j < LENGTH; j++) {
- row.createCell().setCellValue(getFinishFile().get(i)[j])
- }
- }
- FileOutputStream fileOut = new FileOutputStream(PATH + "\workbook.xlsx");
- wb.write(fileOut);
- fileOut.close();
- } catch (EncryptedDocumentException | IOException e | InvalidFormatException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement