Excel Java组件Spire.XLS教程:在Java应用程序中将文本替换为Excel工作表中的图像

*这么优秀的国产工具怎能错过呢!在线下单专享“一口价”,立即购买!想要获取更多福利的朋友可以咨询在线客服哦~

Excel范例:

Excel Java组件Spire.XLS教程:在Java应用程序中将文本替换为Excel工作表中的图像
import com.spire.xls.*;import java.io.IOException;public class replaceTextwithImage {    public static void main(String[] args) throws IOException {        //Load the sample Excel document        Workbook workbook = new Workbook();        workbook.loadFromFile("Sample.xlsx");        //Get the first worksheet        Worksheet worksheet = workbook.getWorksheets().get(0);        //Find the text string {{Image}}        CellRange[] ranges = worksheet.findAllString("{{Image}}", false, false);        for (CellRange range : ranges) {            //set the text as null            range.setText("");            //get the row and column of the searched range            int row = range.getRow();            int column = range.getColumn();            //Add the image to the searched range            worksheet.getPictures().add(row, column, "logo.jpg", ImageFormatType.Jpeg);            //Save the document to file            workbook.saveToFile("replaceTextwithImage.xlsx", ExcelVersion.Version2013);            }        }    }

效果图:

Excel Java组件Spire.XLS教程:在Java应用程序中将文本替换为Excel工作表中的图像


是E-iceblue官方友好合作伙伴,如果您对spire.xls可以联系在线客服了解具体授权价格和使用机制

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年4月4日
下一篇 2021年4月4日

相关推荐

发表回复

登录后才能评论