写作部分效果很好,但我仍在复制它,因为我认为它可能会影响阅读部分。另外,我正在分享我在youtube上关注的视频的链接。
package amalyze;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
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 org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
public class Amalyze {
private static Workbook wbR;
private static Sheet sheetR;
private static FileInputStream fis;
private static FileOutputStream fos;
private static Row rowR;
private static Cell cellR;
public static void main(String[] args) throws IOException, Exception{
//Reading part
fis = new FileInputStream("./amzdata.xlsx");
wbR = WorkbookFactory.create(fis);
sheetR =wbR.getSheet("Sheet1");
// Writing Part
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("FirstExcelSheet");
HSSFRow row = sheet.createRow(0);
HSSFCell cell = row.createCell(7);
cell.setCellValue("str");
workbook.write(new FileOutputStream("Excelamz.xls"));
workbook.close();
}
}
答案 0 :(得分:2)
您可能缺少xmlbeans传递依赖项。
http://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans
我建议使用Maven或Gradle来管理您的依赖项。