小编Kul*_*arY的帖子

使用java将Ms word表的单元格转换为图像

我需要将ms word table的每个单元格转换为图像.我写的代码getImage,以及getText,但我想合并他们两人并转换成单一的形象,所以我只想细胞转换成图像.

参考

XWPFDocument doc = new XWPFDocument(new FileInputStream(fileName));
        List<XWPFTable> table = doc.getTables();
        for (XWPFTable xwpfTable : table) {
            List<XWPFTableRow> row = xwpfTable.getRows();
            for (XWPFTableRow xwpfTableRow : row) {
                List<XWPFTableCell> cell = xwpfTableRow.getTableCells();
                for (XWPFTableCell xwpfTableCell : cell) {
                    if (xwpfTableCell != null) {
                        System.out.println(xwpfTableCell.getText());
                        String s = xwpfTableCell.getText();
                        for (XWPFParagraph p : xwpfTableCell.getParagraphs()) {
                            for (XWPFRun run : p.getRuns()) {
                                for (XWPFPicture pic : run.getEmbeddedPictures()) {
                                    byte[] pictureData = pic.getPictureData().getData();
                                    System.out.println("picture : " + …
Run Code Online (Sandbox Code Playgroud)

java image apache-poi java-canvas

8
推荐指数
1
解决办法
585
查看次数

将MS Word表格单元格提取为图像?

我需要将表格单元格提取为图像.单元格可能包含混合内容(文本+图像),我需要将其合并为单个图像.我能够获得核心文本,但我不知道如何获得图像+文本.不确定Apace POI是否会有所帮助.

有没有人早些做过这样的事情?

  public static void readTablesDataInDocx(XWPFDocument doc) {
    int tableIdx = 1;
    int rowIdx = 1;
    int colIdx = 1;
    List table = doc.getTables();
    System.out.println("==========No Of Tables in Document=============================================" + table.size());
    for (int k = 0; k < table.size(); k++) {
        XWPFTable xwpfTable = (XWPFTable) table.get(k);
        System.out.println("================table -" + tableIdx + "===Data==");
        rowIdx = 1;
        List row = xwpfTable.getRows();
        for (int j = 0; j < row.size(); j++) {
            XWPFTableRow xwpfTableRow = (XWPFTableRow) row.get(j);
            System.out.println("Row -" + rowIdx);
            colIdx …
Run Code Online (Sandbox Code Playgroud)

java apache-poi

6
推荐指数
1
解决办法
336
查看次数

标签 统计

apache-poi ×2

java ×2

image ×1

java-canvas ×1