Tag: apache poi

使用Apache-POI在Excel超链接中设置ScreenTip

我使用POI 3.8来创build使用Java的Excel工作表 我已经创build超链接成功地使用Prashant Jadhav解释如何使用Java中的Apache poi创build超链接到其他工作表上的filter的方法? 不过我也想设置ScreenTip 我试过了 linkPrint.setLabel("Print"); 但无济于事。 这甚至有可能吗? 谢谢!

阅读MS Excel使用Apache POI

我们有一个excel文件,它使用了很多内置的formulas , vlookups , Macros等。我们需要将这个Excel转换为基于Web的解决scheme。 我们可以使用Apache POI吗? 当我们浏览文档时,我们看到它每次读取excel,然后评估公式。 但是对于多个用户访问应用程序,我们不确定是否每次都阅读excel和评估公式。 我们可以将所有的Excel公式转换成Java代码中的方法并从那里调用它吗? 这可以从Apache POI完成吗?

我需要使用Apache POI在Excel工作表中迭代到Java列的末尾

我正在迭代一列值,直到遇到空白。 我需要收集整个专栏并存储它,没有其他值。 我试图检查空白,null,0,“”和CELL_TYPE_BLANK(int = 3),我不能得到它来避免空指针exception。 代码片段和错误如下。 我能做什么? 这不是整个方法或程序,只是相关的一块。 String s = list[i]; //find the directory from the list array to locate the file InputStream input = new FileInputStream(s); //create a new workbook object to hold the excel file Workbook wb = new XSSFWorkbook(input); //create an arbitrary starting location int column = 2; //absolutely the correct […]

下拉列表与POI 3.6

你可以请教我如何创build在Excel表格列中使用POI 3.6的下拉列表? 提前致谢。

用OI-3.5-FINAL将多行写入EXCEL

我有一些数据将它们放入一个Excel表,4个值,n行。 我试过这个: final HSSFWorkbook wb = new HSSFWorkbook(); final HSSFSheet sheet = wb.createSheet(); FileOutputStream stream; HSSFRow row = null; try { stream = new FileOutputStream(targetDirectory + "workbook.xls"); for (int i = 1; i < data.size(); i++) { row = sheet.createRow((short) i); cell = row.createCell(0); cell.setCellValue("Das"); cell = row.createCell(1); cell.setCellValue("hier"); cell = row.createCell(2); cell.setCellValue("soll"); cell = […]

Apache poi单元格格式(°)度标志

我正在使用apache poi-3.9创build带有一些测量数据的Excel(xls)工作表,这些测量数据应该在单元格内以单位显示。 单位是毫巴,毫米/秒和(°)度。 对于毫巴和毫米/秒的一切工作完全正常,但程度格式会丢失。 Microsoft Excel抱怨与以下错误消息:“文件错误。一些数字格式可能已丢失。 这是我的代码: 最终的HSSFWorkbook hssfWorkbook =新的HSSFWorkbook(); final HSSFCellStyle cellStyleMbar = hssfWorkbook.createCellStyle(); final HSSFCellStyle cellStyleDegree = hssfWorkbook.createCellStyle(); cellStyleMbar.setDataFormat(dataFormat.getFormat(“0 \”mbar \“”)); cellStyleDegree.setDataFormat(dataFormat.getFormat(“0.0 \”°C“)); 感谢您的想法!

使用Apache POI创build简单工作簿时出错

我正在尝试使用Apache POI创build一个简单的工作簿,并得到以下错误。使用apchhe poi 3.9请帮助我摆脱这种感谢。 错误: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException at xlscreate.xlsclass.main(xlsclass.java:24) Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) … 1 more 码: import java.io.FileOutputStream; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io.InputStream; public class xlsclass { public […]

如何在客户端创build一个Excel电子表格

我正在创build一个Web应用程序,我想在结果中显示一个Excel图标。 当用户点击图标时,应该在客户机上打开一个电子表格,其中有一些数据由服务器发送(客户端将安装excel)。 我写了一些代码来从web服务在本地机器上创buildexcel。 public class App { public static void main( String[] args ) { try { URL oracle = new URL("http://someService.com"); URLConnection yc =null; yc = oracle.openConnection(); //Get the workbook instance for XLS file HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Sample sheet"); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; […]

使用Apache POI和TestNG框架将数据写入excel

我正在尝试使用Apache POI将数据写入excel表单。我正在使用TestNG framerwork和eclipse IDE。 程序正在成功执行,没有任何错误。但是当我点击我的项目源的刷新,excel工作表不会来。 请告诉我,我将如何看到我生成的Excel表单。 我的代码如下: public class Test { public static void main(String args[]) { try { FileOutputStream fos = new FileOutputStream("User.xls"); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet worksheet = workbook.createSheet("worksheet"); HSSFRow row1 = worksheet.createRow((short) 0); HSSFCell cell1 = row1.createCell((short) 0); cell1.setCellValue("abc"); HSSFCell cell2 = row1.createCell((short) 1); cell2.setCellValue("123"); workbook.write(fos); fos.close(); } catch (FileNotFoundException […]

导出variables从查询到excel的列数

我正在尝试将复杂查询的输出写入Excel。 为此,我使用JDBC并创build了一个返回types“ResultSet”的函数,通过该函数我将获取Query的输出。 要将ResultSet行写入excel,我应该这样做: HSSFRow row = firstSheet.createRow(index); row.createCell(0).setCellValue(rs.getInt(1)); row.createCell(1).setCellValue(rs.getInt(2)); row.createCell(2).setCellValue(rs.getString(2)); row.createCell(3).setCellValue(rs.getString(3)); 现在的问题是,复杂查询的结果集包括可变数量的行和列取决于我们运行查询需要导出到Excel的date。 有没有可行的方法通过编程我可以处理这种情况,并将查询结果导出到Excel中。 提前致谢。