|
@@ -18,7 +18,7 @@ public class Picture {
|
|
|
public static void main(String[] args) throws Exception {
|
|
public static void main(String[] args) throws Exception {
|
|
|
/* Create a Workbook and Worksheet */
|
|
/* Create a Workbook and Worksheet */
|
|
|
XSSFWorkbook my_workbook = new XSSFWorkbook();
|
|
XSSFWorkbook my_workbook = new XSSFWorkbook();
|
|
|
- XSSFSheet my_sheet = my_workbook.createSheet("MyLogo");
|
|
|
|
|
|
|
+ XSSFSheet sheet = my_workbook.getSheetAt(0);//获取第一个sheet
|
|
|
/* Read input PNG / JPG Image into FileInputStream Object*/
|
|
/* Read input PNG / JPG Image into FileInputStream Object*/
|
|
|
InputStream my_banner_image = new FileInputStream("d:\\1.png");
|
|
InputStream my_banner_image = new FileInputStream("d:\\1.png");
|
|
|
/* Convert picture to be added into a byte array */
|
|
/* Convert picture to be added into a byte array */
|
|
@@ -28,7 +28,7 @@ public class Picture {
|
|
|
/* Close the InputStream. We are ready to attach the image to workbook now */
|
|
/* Close the InputStream. We are ready to attach the image to workbook now */
|
|
|
my_banner_image.close();
|
|
my_banner_image.close();
|
|
|
/* Create the drawing container */
|
|
/* Create the drawing container */
|
|
|
- XSSFDrawing drawing = my_sheet.createDrawingPatriarch();
|
|
|
|
|
|
|
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
|
|
|
/* Create an anchor point */
|
|
/* Create an anchor point */
|
|
|
XSSFClientAnchor my_anchor = new XSSFClientAnchor();
|
|
XSSFClientAnchor my_anchor = new XSSFClientAnchor();
|
|
|
/* Define top left corner, and we can resize picture suitable from there */
|
|
/* Define top left corner, and we can resize picture suitable from there */
|