Shape类用来读取Word中的图形、图片,一个Shape对象表明Word中的一个图片。服务器
在线编辑Word文件时,有时可能会须要读取或导出Word文件中的图形、图片,这时就须要经过Shape类来实现了,它能经过将Shape对象的saveAsJPG("saveAsFileName")方法将Word中的图形、图像保存成一个JPG图片文件。
Shape对象的获取可经过如下两种方法:spa
Java代码:code
WordDocument doc = new WordDocument(request,response);//注意参数 DataRegion dataRegion = doc.openDataRegion("PO_img"); Shape shape = dataRegion.openShape(1); //参数为Word中Shape的索引,从“1”开始 shape.saveAsJPG("D:\\test.jpg");//保存到服务器磁盘目录下 ... ...
ASP.NET代码:对象
WordDocument doc = new WordDocument(); DataRegion dataRegion = doc.OpenDataRegion("PO_img"); Shape shape = dataRegion.OpenShape(1); //参数为Word中Shape的索引,从“1”开始 shape.SaveAsJPG("D:\\test.jpg");//保存到服务器磁盘目录下 ... ...
Java代码:索引
... ... Cell cell = table.openCellRC(2,3); //获取某个Cell对象 //List<Shape> shapes = cell.getShapes(); //获取Cell里包含的 Shape 集合 //Shape shape = shapes.get(index); //获取集合中的某个Shape对象 Shape shape = cell.openShape(1); //获取Cell中的某个Shape对象,索引从“1”开始 shape.saveAsJPG("D:\\test.jpg"); //保存到服务器磁盘目录下 ... ...
ASP.NET代码:图片
... ... Cell cell = table.OpenCellRC(2,3); //获取某个Cell对象 //ArrayList shapes = cell.Shapes; //获取Cell里包含的 Shape 集合 //Shape shape = shapes[index]; //获取集合中的某个Shape对象 Shape shape = cell.OpenShape(1); //获取Cell中的某个Shape对象,索引从“1”开始 shape.SaveAsJPG("D:\\test.jpg"); //保存到服务器磁盘目录下