Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
Uploader
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Uploader
Commits
31569226
Commit
31569226
authored
Feb 23, 2018
by
Maxym Borodenko
Committed by
Matija Obreza
Feb 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved Excel source
fix row handler
parent
ff6e4078
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
anno-gui/src/main/java/org/genesys2/anno/reader/MyXSSFSheetHandler.java
...ain/java/org/genesys2/anno/reader/MyXSSFSheetHandler.java
+20
-10
No files found.
anno-gui/src/main/java/org/genesys2/anno/reader/MyXSSFSheetHandler.java
View file @
31569226
/**
* Copyright 201
4
Global Crop Diversity Trust
* Copyright 201
8
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -16,10 +16,13 @@
package
org.genesys2.anno.reader
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
org.apache.poi.ss.usermodel.BuiltinFormats
;
import
org.apache.poi.ss.usermodel.DateUtil
;
import
org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable
;
import
org.apache.poi.xssf.model.StylesTable
;
import
org.apache.poi.xssf.usermodel.XSSFCellStyle
;
...
...
@@ -134,15 +137,15 @@ public class MyXSSFSheetHandler extends DefaultHandler {
// c => cell
else
if
(
"c"
.
equals
(
name
))
{
// Get the cell reference
String
r
=
attributes
.
getValue
(
"r"
);
final
String
newColRef
=
attributes
.
getValue
(
"r"
);
int
firstDigit
=
-
1
;
for
(
int
c
=
0
;
c
<
r
.
length
();
++
c
)
{
if
(
Character
.
isDigit
(
r
.
charAt
(
c
)))
{
for
(
int
c
=
0
;
c
<
newColRef
.
length
();
++
c
)
{
if
(
Character
.
isDigit
(
newColRef
.
charAt
(
c
)))
{
firstDigit
=
c
;
break
;
}
}
thisColumn
=
nameToColumn
(
r
.
substring
(
0
,
firstDigit
));
thisColumn
=
nameToColumn
(
newColRef
.
substring
(
0
,
firstDigit
));
// Set up defaults.
this
.
nextDataType
=
xssfDataType
.
NUMBER
;
...
...
@@ -225,8 +228,11 @@ public class MyXSSFSheetHandler extends DefaultHandler {
break
;
case
NUMBER:
String
n
=
value
.
toString
();
if
(
n
.
contains
(
"."
))
final
String
n
=
value
.
toString
();
if
(
DateUtil
.
isADateFormat
(
this
.
formatIndex
,
this
.
formatString
))
{
final
Date
date
=
DateUtil
.
getJavaDate
(
Double
.
valueOf
(
n
));
thisObj
=
new
SimpleDateFormat
(
"yyyyMMdd"
).
format
(
date
);
}
else
if
(
n
.
contains
(
"."
))
thisObj
=
Double
.
parseDouble
(
n
);
else
thisObj
=
Long
.
parseLong
(
n
);
...
...
@@ -247,9 +253,14 @@ public class MyXSSFSheetHandler extends DefaultHandler {
// Emit commas for any fields that were missing on this row
if
(
lastColumnNumber
==
-
1
)
{
lastColumnNumber
=
0
;
for
(
int
i
=
lastColumnNumber
;
i
<
thisColumn
;
++
i
)
{
row
.
add
(
""
);
}
}
else
{
for
(
int
i
=
lastColumnNumber
;
i
<
thisColumn
-
1
;
++
i
)
{
row
.
add
(
""
);
}
}
for
(
int
i
=
lastColumnNumber
;
i
<
thisColumn
-
1
;
++
i
)
row
.
add
(
null
);
// Might be the empty string.
row
.
add
(
thisObj
);
...
...
@@ -314,5 +325,4 @@ public class MyXSSFSheetHandler extends DefaultHandler {
}
return
column
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment