冰蓝科技
|
028-81705109
|
|
微信扫一扫
|

Spire.Cloud 纯前端文档控件

以下内容介绍使用Spire.XLS for Java 设置Excel表格视图模式的方法。

import com.spire.xls.*;

public class SetViewMode {
    public static void main(String[] args) {
        //加载Excel工作簿
        Workbook wb = new Workbook();
        wb.loadFromFile("test.xlsx");

        //获取工作表
        Worksheet sheet = wb.getWorksheets().get(0);

        //设置工作表视图模式
        //sheet.setViewMode(ViewMode.Normal);
        sheet.setViewMode(ViewMode.Layout);
        //sheet.setViewMode(ViewMode.Preview);

        //保存文档
        wb.saveToFile("SetViewMode.xlsx");
        wb.dispose();
    }
}

设置效果:

Java 设置 Excel 视图模式

Spire.PDF 7.4.13已发布。该版本支持了在转换PDF到Excel时设置根据线条决定单元格的功能,新增了PrintSettings.IsValid属性的功能以判断打印机是否可以使用,增强了转换PDF到图片/Excel/XPS的功能,以及修复了打印PDF文档等时出现的问题。详情请阅读以下内容。

新功能:

问题修复:


获取Spire.PDF 7.4.13请点击:

获取Spire.PDF 7.4.13请点击:https://www.e-iceblue.cn/Downloads/Spire-PDF-NET.html

本文介绍如何使用Spire.XLS for Java在Excel表格中,用图片替换文字。

原文档:

Java 用图片替换 Excel 表格中的特定文本

import com.spire.xls.*;
import java.io.IOException;

public class ReplaceTextWithImage {
    public static void main(String[] args) throws IOException {

        //加载Excel示例文档
        Workbook workbook = new Workbook();
        workbook.loadFromFile("Sample.xlsx");
        //获取第一张工作表
        Worksheet worksheet = workbook.getWorksheets().get(0);

        //查找文档中的字符串“图片”
        CellRange[] ranges = worksheet.findAllString("{{图片}}", false, false);
        for (CellRange range : ranges) {
            //重置文本为空
            range.setText("");

            //获取单元格所在的行列
            int row = range.getRow();
            int column = range.getColumn();
            //添加图片到获取的单元格
            worksheet.getPictures().add(row, column, "logo.jpg", ImageFormatType.Jpeg);

            //保存文档
            workbook.saveToFile("replaceTextwithImage.xlsx", ExcelVersion.Version2013);
            }
        }
    }

效果图:

Java 用图片替换 Excel 表格中的特定文本

Spire.Presentation for Java 4.4.2已发布。本次更新主要优化了插入图片耗时长的问题,并且增强了转换PPT到PDF的功能。此外,该版本还修复了加载PPT文档等时出现的问题。详情请阅读以下内容。

优化:

问题修复:


获取Spire.Presentation for Java 4.4.2请点击:

https://www.e-iceblue.cn/Downloads/Spire-Presentation-JAVA.html

在开发团队的共同努力之下,冰蓝科技于今日正式推出了Spire.Doc for Android via Java 2.4.0。该产品是一款专业的 Android Word 开发组件,用于 Android 应用程序中创建、转换、操作和打印 Word 文档。作为一款完全独立的组件,其运行环境无需安装 Microsoft Word。以下是该产品的主要功能:


获取Spire.Doc for Android via Java 2.4.0更详细的信息,请点击:

https://www.e-iceblue.cn/Introduce/doc-for-android-via-java.html

本文介绍如何使用Spire.Doc for Java将ASCII字符设置为Word文档中的列表符号。

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.Section;
import com.spire.doc.documents.ListStyle;
import com.spire.doc.documents.ListType;
import com.spire.doc.documents.Paragraph;

public class SetBulletPoints {

    public static void main(String[] args) {

        //创建Document对象并添加节
        Document doc = new Document();
        Section section = doc.addSection();

        //根据不同的ASCII字符创建四种不同的列表样式
        ListStyle listStyle1 = new ListStyle(doc, ListType.Bulleted);
        listStyle1.getLevels().get(0).setBulletCharacter("\u006e");
        listStyle1.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle1.setName("liststyle1");
        doc.getListStyles().add(listStyle1);
        ListStyle listStyle2 = new ListStyle(doc, ListType.Bulleted);
        listStyle2.getLevels().get(0).setBulletCharacter("\u0075");
        listStyle2.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle2.setName("liststyle2");
        doc.getListStyles().add(listStyle2);
        ListStyle listStyle3 = new ListStyle(doc, ListType.Bulleted);
        listStyle3.getLevels().get(0).setBulletCharacter("\u00b2");
        listStyle3.getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle3.setName("liststyle3");
        doc.getListStyles().add(listStyle3);
        ListStyle listStyle4 = new ListStyle(doc, ListType.Bulleted);
        listStyle4 .getLevels().get(0).setBulletCharacter("\u00d8");
        listStyle4 .getLevels().get(0).getCharacterFormat().setFontName("Wingdings");
        listStyle4.setName("liststyle4");
        doc.getListStyles().add(listStyle4);

        //添加四个段落并分别应用列表样式
        Paragraph p1 = section.getBody().addParagraph();
        p1.appendText("Spire.Doc for .NET");
        p1.getListFormat().applyStyle(listStyle1.getName());
        Paragraph p2 = section.getBody().addParagraph();
        p2.appendText("Spire.PDF for .NET");
        p2.getListFormat().applyStyle(listStyle2.getName());
        Paragraph p3 = section.getBody().addParagraph();
        p3.appendText("Spire.XLS for .NET");
        p3.getListFormat().applyStyle(listStyle3.getName());
        Paragraph p4= section.getBody().addParagraph();
        p4.appendText("Spire.Presentation for .NET");
        p4.getListFormat().applyStyle(listStyle4.getName());

        //保存到文档
        doc.saveToFile("output/SetBulletCharacter.docx", FileFormat.Docx);
    }
}

Java 将 ASCII 字符设置为 Word 列表符号

本文介绍使用Spire.Doc for Java删除Word目录的方法。

import com.spire.doc.*;
import com.spire.doc.documents.Paragraph;

public class RemoveTOC {
    public static void main(String[]args){
        //加载包含目录的Word文档
        Document doc = new Document();
        doc.loadFromFile("https://cdn.e-iceblue.cn/sample.docx");

        //获取section
        Section section = doc.getSections().get(0);

         //遍历段落
        for (int i = 0; i < section.getParagraphs().getCount(); i++)
        {
            Paragraph paragraph = section.getParagraphs().get(i);
            if (paragraph.getStyleName().matches("TOC\\w+"))
            {
                section.getParagraphs().removeAt(i);//删除目录
                i--;
            }
        }

         //保存文档
        doc.saveToFile("RemoveTOC.docx", FileFormat.Docx_2013);
        doc.dispose();
    }
}

目录删除效果前后:

Java 删除 Word 目录

Spire.XLS for Java支持将Word, Excel, PowerPoint幻灯片和PDF文档以OLE 对象嵌入到Excel工作表。本文将详细介绍如何使用Spire.Xls将Word文档作为OLE对象插入到Excel工作表。

import com.spire.xls.*;
import com.spire.xls.core.IOleObject;
import com.spire.doc.*;
import com.spire.doc.documents.ImageType;
import java.awt.image.BufferedImage;

public class insertOLEObjects {
    public static void main(String[] args) {
        String docFile = "Sample.docx";
        String outputFile = "output/insertOLEObjects_result.xlsx";

        //加载Excel文档
        Workbook workbook = new Workbook();
        workbook.loadFromFile("Sample.xlsx");
        //获取第一张工作表
        Worksheet worksheet = workbook.getWorksheets().get(0);

        //生成图片
        BufferedImage image = GenerateImage(docFile);
        //插入OLE对象
        IOleObject oleObject = worksheet.getOleObjects().add(docFile, image, OleLinkType.Embed);
        oleObject.setLocation(worksheet.getCellRange("B4"));
        oleObject.setObjectType(OleObjectType.ExcelWorksheet);
        //保持文档
        workbook.saveToFile(outputFile, ExcelVersion.Version2010);
    }

    private static BufferedImage GenerateImage(String fileName) {

        //加载Word文档
        Document document = new Document();
        document.loadFromFile(fileName);

        //将Word文档的第一页保存为图片
        BufferedImage image = document.saveToImages(0, ImageType.Bitmap);
        return image;
    }
}

效果图:

Java 插入 OLE 对象到 Excel

Spire.Office 6.4.2已发布。本次更新带来一些新的功能,比如:Spire.PDF支持根据图片的位置删除图片,并新增设置Check Box Field的导出值的功能。同时,该版本还修复了大量已知问题。详情请阅读以下内容。

该版本涵盖了最新版的Spire.Doc, Spire.PDF, Spire.XLS, Spire.Presentation, Spire.Email, Spire.DocViewer, Spire.PDFViewer, Spire.Spreadsheet, Spire.OfficeViewer, Spire.DataExport, Spire.Barcode。

版本信息如下:

获取Spire.Office 6.4.2请点击:

https://www.e-iceblue.cn/Downloads/Spire-Office-NET.html


Spire.Doc

问题修复:

Spire.PDF for Java 4.4.5已发布。该版本查找换行文本时,支持返回所有的矩形区域信息。同时,本次更新还增强了转换PDF到Word/PDF/A-3B/PDFA1A等时的功能。详情请阅读以下内容。

新功能:

问题修复:


获取Spire.PDF for Java 4.4.5请点击:

https://www.e-iceblue.cn/Downloads/Spire-PDF-JAVA.html