FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
excel_pdf/JavaTPCProject/src/Project03_B.java at master · TypeP/excel_pdf · GitHub
TypeP
excel_pdf
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
excel_pdf
/
JavaTPCProject
/
src
/
Project03_B.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (35 loc) · 1.2 KB
Breadcrumbs
excel_pdf
/
JavaTPCProject
/
src
/
Project03_B.java
Copy path
File metadata and controls
48 lines (35 loc) · 1.2 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
import
java
.
io
.*;
import
org
.
apache
.
poi
.
hssf
.
usermodel
.
HSSFWorkbook
;
import
org
.
apache
.
poi
.
ss
.
usermodel
.*;
import
org
.
apache
.
poi
.
util
.
IOUtils
;
public
class
Project03_B
{
public
static
void
main
(
String
[]
args
) {
try
{
Workbook
wb
=
new
HSSFWorkbook
();
Sheet
sheet
=
wb
.
createSheet
(
"My Sample Excel"
);
InputStream
is
=
new
FileInputStream
(
"pic.jpg"
);
byte
[]
bytes
=
IOUtils
.
toByteArray
(
is
);
int
pictureIdx
=
wb
.
addPicture
(
bytes
,
Workbook
.
PICTURE_TYPE_JPEG
);
is
.
close
();
CreationHelper
helper
=
wb
.
getCreationHelper
();
Drawing
drawing
=
sheet
.
createDrawingPatriarch
();
ClientAnchor
anchor
=
helper
.
createClientAnchor
();
anchor
.
setCol1
(
1
);
anchor
.
setRow1
(
2
);
anchor
.
setCol2
(
2
);
anchor
.
setRow2
(
3
);
Picture
pict
=
drawing
.
createPicture
(
anchor
,
pictureIdx
);
Cell
cell
=
sheet
.
createRow
(
2
).
createCell
(
1
);
int
w
=
20
*
256
;
sheet
.
setColumnWidth
(
1
,
w
);
short
h
=
120
*
20
;
cell
.
getRow
().
setHeight
(
h
);
FileOutputStream
fileOut
=
new
FileOutputStream
(
"myFile.xls"
);
wb
.
write
(
fileOut
);
fileOut
.
close
();
System
.
out
.
println
(
"이미지 생성 성공"
);
}
catch
(
Exception
e
) {
e
.
printStackTrace
();
}
}
}
Back
|
FazBrowse Home
|
New Git URL