Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void writeApachePoi() {
- String state = Environment.getExternalStorageState();
- if (Environment.MEDIA_MOUNTED.equals(state)) {
- File root = Environment.getExternalStorageDirectory();
- File dir = new File(root.getAbsolutePath() + "/Teacher");
- if (!dir.exists())
- dir.mkdir();
- File manager = new File(dir, "writeApachePoi.docx");
- try {
- XWPFDocument document= new XWPFDocument();
- XWPFParagraph paragraph = document.createParagraph();
- XWPFRun run=paragraph.createRun();
- run.setText("The Body:");
- XWPFTable table = document.createTable(1, 2);
- ***table.setInsideHBorder( XWPFTable.XWPFBorderType.SINGLE, 4, 0, "FF0000");***
- table.setWidth(5*1540); //should be 5 inches width
- CTTblWidth tblWidth = table.getRow(0).getCell(0).getCTTc().addNewTcPr().addNewTcW();
- tblWidth.setW(BigInteger.valueOf(2*1440));
- tblWidth.setType(STTblWidth.DXA);
- tblWidth = table.getRow(0).getCell(1).getCTTc().addNewTcPr().addNewTcW();
- tblWidth.setW(BigInteger.valueOf(4*1440));
- tblWidth.setType(STTblWidth.DXA);
- XWPFTableRow tableRowOne = table.getRow(0);
- tableRowOne.getCell(0).setText("CLientID");
- tableRowOne.getCell(1).setText("CID001");
- XWPFTableRow tableRow2 = table.createRow();
- tableRow2.getCell(0).setText("AccountID");
- tableRow2.getCell(1).setText("ACCID001");
- FileOutputStream stream = new FileOutputStream(manager);
- document.write(stream);
- stream.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment