FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-code-example/ExcelApi/src/ReadExample.java at master · cherkavi/java-code-example · GitHub
cherkavi
/
java-code-example
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
0
Code
Issues
0
Pull requests
42
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-code-example
/
ExcelApi
/
src
/
ReadExample.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
49 lines (44 loc) · 1.42 KB
Breadcrumbs
java-code-example
/
ExcelApi
/
src
/
ReadExample.java
Copy path
File metadata and controls
executable file
·
49 lines (44 loc) · 1.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import
jxl
.*;
import
jxl
.
write
.
Label
;
import
jxl
.
write
.
WritableSheet
;
import
jxl
.
write
.
WritableWorkbook
;
import
java
.
io
.*;
public
class
ReadExample
{
public
static
void
main
(
String
[]
args
){
try
{
String
pathToFile
=
"d:
\\
temp.xls"
;
write
(
pathToFile
);
read
(
pathToFile
);
}
catch
(
Exception
ex
){
System
.
err
.
println
(
"ReadExample Exception:"
+
ex
.
getMessage
());
}
}
private
static
void
write
(
String
pathToFile
)
throws
Exception
{
// settings for workbook
WorkbookSettings
settings
=
new
WorkbookSettings
();
settings
.
setEncoding
(
"WINDOWS-1251"
);
// create and open workbook
WritableWorkbook
workbook
=
Workbook
.
createWorkbook
(
new
File
(
pathToFile
),
settings
);
// create sheet into workbook
WritableSheet
sheet
=
workbook
.
createSheet
(
"ëèñò îäèí"
,
0
);
// cell format
CellView
cellView
=
new
CellView
();
cellView
.
setSize
(
10000
);
// set cell format
sheet
.
setColumnView
(
0
,
cellView
);
// add cell into sheet
sheet
.
addCell
(
new
Label
(
0
,
0
,
"ýòî âðåìåííîå çíà÷åíèå"
));
// write workbook
workbook
.
write
();
workbook
.
close
();
}
private
static
void
read
(
String
pathToFile
)
throws
Exception
{
Workbook
workbook
=
Workbook
.
getWorkbook
(
new
File
(
pathToFile
));
Sheet
sheet
=
workbook
.
getSheet
(
0
);
Cell
[]
columnOne
=
sheet
.
getColumn
(
0
);
for
(
int
counter
=
0
;
counter
<
columnOne
.
length
;
counter
++){
System
.
out
.
println
(
sheet
.
getCell
(
0
,
counter
).
getContents
());
}
workbook
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL