forked from bitcocom/JavaTPCProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject03_B.java
More file actions
44 lines (35 loc) · 1.17 KB
/
Project03_B.java
File metadata and controls
44 lines (35 loc) · 1.17 KB
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
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();
}
}
}