POI读取EXCEL 顶。用POI可以用sheet.rowIterator();取得行数,但怎么取得列数呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一个操作excel的例子,看对你有帮助否package excel;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.hssf.usermodel.HSSFSheet;import org.apache.poi.hssf.usermodel.HSSFRow;import org.apache.poi.hssf.usermodel.HSSFCell;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;public class ReadWriteWorkbook{ public static void main(String[] args) throws IOException { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("d:\\foo.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); wb.removeSheetAt(2); HSSFSheet sheet = wb.getSheetAt(0); sheet.setColumnWidth((short)200,(short)500); HSSFRow row = sheet.getRow(2); if (row == null) row = sheet.createRow(2); HSSFCell cell = row.getCell((short)3); if (cell == null) cell = row.createCell((short)3); cell.setCellType(HSSFCell.CELL_TYPE_STRING); cell.setCellValue("asafasfsafasfsfaas test"); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("d:\\ffoo.xls"); wb.write(fileOut); fileOut.close(); }} 新手学习,绘制自定义控件问题 编译时找不到符号 一个很简单的小程序,帮忙看下,就几行代码 谁能给出工厂模式的UML图?谢谢 请问大家:这个“贪吃蛇”代码怎么有语法错误? 如何在一个JDesktopPane 只能存在一个JInternalFrame? 小弟初学java就出现了一个错误,请大家帮忙阿。 java中的密码框?? 有谁用过SourceForce.net的HtmlParser API,有事相求。 求救!!!这些出错信息是什么意思 java有没有能实现定时功能的包? 有关求最大的两个数值的问题
package excel;import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;public class ReadWriteWorkbook
{
public static void main(String[] args)
throws IOException
{
POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream("d:\\foo.xls"));
HSSFWorkbook wb = new HSSFWorkbook(fs);
wb.removeSheetAt(2);
HSSFSheet sheet = wb.getSheetAt(0);
sheet.setColumnWidth((short)200,(short)500); HSSFRow row = sheet.getRow(2);
if (row == null)
row = sheet.createRow(2);
HSSFCell cell = row.getCell((short)3);
if (cell == null)
cell = row.createCell((short)3);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue("asafasfsafasfsfaas test");
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("d:\\ffoo.xls");
wb.write(fileOut);
fileOut.close();
}
}