
FileInputStream fileInputStream = new FileInputStream( soureFile)
POIFSFileSystem pfs = new POIFSFileSystem( fileInputStream )
HWPFDocument hwpf = new HWPFDocument(pfs)// make a HWPFDocument object
OutputStream output = new FileOutputStream( targetFile )
hwpf.write(output)// write to the target file
output.close()
Table tcDataTable = range.insertTableBefore( (short)column , row)//column and row列数和行数
tcDataTable.getRow(i).getCell(j).getParagraph(0).getCharacterRun(0).insertBefore("插入i行j列的内容" )
XWPF的情况:
String outputFile = "D:\\test.doc"
XWPFDocument document = new XWPFDocument()
XWPFTable tableOne = document.createTable()
XWPFTableRow tableOneRowOne = tableOne.getRow(0)
tableOneRowOne.getCell(0).setText("11")
XWPFTableCell cell12 = tableOneRowOne.createCell()
cell12.setText("12")
// tableOneRowOne.addNewTableCell().setText("第1行第2列")
// tableOneRowOne.addNewTableCell().setText("第1行第3列")
// tableOneRowOne.addNewTableCell().setText("第1行第4列")
XWPFTableRow tableOneRowTwo = tableOne.createRow()
tableOneRowTwo.getCell(0).setText("21")
tableOneRowTwo.getCell(1).setText("22")
// tableOneRowTwo.getCell(2).setText("第2行第3列")
XWPFTableRow tableOneRow3 = tableOne.createRow()
tableOneRow3.addNewTableCell().setText("31")
tableOneRow3.addNewTableCell().setText("32")
FileOutputStream fOut
try {
fOut = new FileOutputStream(outputFile)
document.write(fOut)
fOut.flush()
// *** 作结束,关闭文件
fOut.close()
} catch (Exception e) {
e.printStackTrace()
}
poippt表格添加行没有样式一、首先鼠标左键点击一下插入的表格,这样就选中了该表格。
二、接着鼠标左键按着不放,拖动选中全部单元格。
三、点击表格工具栏内的“样式”,选择一个所需的样式。
四、接着点击“边框线”,下拉菜单内点击“所有框线”。
五、这时就能够为该表格内的所有单元格设置边框了。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)