Skip to content
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

Change poi-ooxml version to 4.1.1 #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ distributions {
}

dependencies {
implementation("org.apache.poi:poi-ooxml:3.12")
implementation("org.apache.poi:poi-ooxml:4.1.1")
implementation("org.apache.odftoolkit:simple-odf:0.8.2-incubating")
implementation("com.google.code.findbugs:jsr305:3.0.2")
}
Expand Down
32 changes: 15 additions & 17 deletions src/main/java/com/ka/spreadsheet/diff/SpreadSheetExcel.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.ka.spreadsheet.diff;

import java.util.Iterator;
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to not import *

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import javax.annotation.Nullable;

import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.ss.usermodel.Cell;
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.xssf.usermodel.XSSFWorkbook;
import java.util.Iterator;

public class SpreadSheetExcel implements ISpreadSheet {

Expand Down Expand Up @@ -50,10 +46,12 @@ public void remove() {
public Boolean hasMacro() {
if (workbook instanceof XSSFWorkbook) {
for (POIXMLDocumentPart p : ((XSSFWorkbook) workbook).getRelations()) {
if ((p.getPackageRelationship() != null)
&& (p.getPackageRelationship().getTargetURI() != null)
&& (p.getPackageRelationship().getTargetURI().toString().contains("vbaProject"))) {
return true;
for (POIXMLDocumentPart.RelationPart part: p.getRelationParts()) {
if ((part.getRelationship() != null)
&& (part.getRelationship().getTargetURI() != null)
&& (part.getRelationship().getTargetURI().toString().contains("vbaProject"))) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -167,20 +165,20 @@ public CellValue getValue() {
boolean hasFormula = false;
String formula = null;
Object value = null;
int cellType = cell.getCellType();
if (cellType == Cell.CELL_TYPE_FORMULA) {
CellType cellType = cell.getCellType();
if (cellType == CellType.FORMULA) {
hasFormula = true;
formula = cell.getCellFormula();
cellType = cell.getCachedFormulaResultType();
}
switch (cellType) {
case Cell.CELL_TYPE_NUMERIC:
case NUMERIC:
value = cell.getNumericCellValue();
break;
case Cell.CELL_TYPE_BOOLEAN:
case BOOLEAN:
value = cell.getBooleanCellValue();
break;
case Cell.CELL_TYPE_ERROR:
case ERROR:
value = String.valueOf(cell.getErrorCellValue());
break;
default:
Expand Down