1

i have a document excel with textboxes i want to create in this textboxes a text from java code this is the code to get value , how i'm going to edit it using poid apache

    try {
     FileInputStream fsIP = new FileInputStream(new File("C:\\Book1.xls"));

     //   InputStream input = new FileInputStream("Book1.xls");
        POIFSFileSystem fs = new POIFSFileSystem(fsIP);
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheetAt(0);
        HSSFPatriarch pat = sheet.getDrawingPatriarch();
        List children = pat.getChildren();

        Iterator it = children.iterator();
        while (it.hasNext()) {
            HSSFShape shape = (HSSFShape) it.next();
            if (shape instanceof HSSFTextbox) {

                shape.getAnchor()
                HSSFTextbox textbox = (HSSFTextbox) shape;
                HSSFRichTextString richString = textbox.getString();
                String str = richString.getString();
                System.out.println("String: " + str);
                System.out.println("String length: " + str.length());
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }
lomed
  • 51
  • 7

0 Answers0