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
08967a90
Commit
08967a90
authored
Feb 27, 2019
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed skiprows for Excel sheets
parent
706f7425
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
+16
-17
anno-gui/src/main/java/org/genesys2/anno/parser/XlsxRowReader.java
...src/main/java/org/genesys2/anno/parser/XlsxRowReader.java
+16
-17
No files found.
anno-gui/src/main/java/org/genesys2/anno/parser/XlsxRowReader.java
View file @
08967a90
...
...
@@ -54,6 +54,10 @@ public class XlsxRowReader implements RowReader {
private
Queue
<
Object
[]>
rowsQueue
=
new
LinkedBlockingQueue
<
Object
[]>(
MAX_XLSXREADER_BUFFER
);
private
int
skipRows
=
0
;
private
int
rowCount
=
0
;
public
XlsxRowReader
(
File
sourceFile
,
String
sheetName
)
{
if
(
sheetName
==
null
)
{
throw
new
IllegalArgumentException
(
"sheetName cannot be null"
);
...
...
@@ -115,7 +119,7 @@ public class XlsxRowReader implements RowReader {
}
List
<
Object
[]>
readRows
=
new
ArrayList
<
Object
[]>(
rowsToRead
);
for
(;
rowsToRead
>
0
;
rowsToRead
--)
{
do
{
while
(
rowsQueue
.
size
()
==
0
)
{
_log
.
debug
(
"Queue is empty."
);
try
{
...
...
@@ -130,15 +134,23 @@ public class XlsxRowReader implements RowReader {
return
readRows
;
}
}
readRows
.
add
(
rowsQueue
.
poll
());
}
Object
[]
row
=
rowsQueue
.
poll
();
rowCount
++;
if
(
skipRows
>=
rowCount
)
{
_log
.
debug
(
"Skipping row "
+
rowCount
+
" skipRows="
+
skipRows
);
continue
;
}
readRows
.
add
(
row
);
}
while
(
readRows
.
size
()
<
rowsToRead
);
return
readRows
;
}
@Override
public
void
setSkipRows
(
int
skipRows
)
{
th
readedReader
.
setSkipRows
(
skipRows
)
;
th
is
.
skipRows
=
skipRows
;
}
@Override
...
...
@@ -167,8 +179,6 @@ public class XlsxRowReader implements RowReader {
private
XMLReader
parser
;
private
InputStream
sheet
;
private
int
startAt
=
0
;
int
rowCount
=
0
;
private
Queue
<
Object
[]>
rows
;
private
OPCPackage
pkg
;
...
...
@@ -200,10 +210,6 @@ public class XlsxRowReader implements RowReader {
this
.
pkg
=
null
;
}
public
void
setSkipRows
(
int
skipRows
)
{
this
.
startAt
=
skipRows
;
}
@Override
public
void
run
()
{
try
{
...
...
@@ -237,13 +243,6 @@ public class XlsxRowReader implements RowReader {
throw
new
StopParsingException
(
"Xlsx reader thread was interrupted. Stop parsing."
);
}
rowCount
++;
if
(
startAt
>=
rowCount
)
{
_log
.
debug
(
"Skipping row "
+
rowCount
+
" startAt="
+
startAt
);
return
;
}
while
(
true
)
{
try
{
rows
.
add
(
row
);
...
...
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