我有一个文档 excel 文本框 我想在这个文本框中创建一个来自java代码的文本 这是获取价值的代码,我将如何使用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();
}