@Deprecated
public final class ExcelRWUtil
extends java.lang.Object
implements java.io.Serializable
try {
Excel readExcel = new Excel();
readExcel.setFilePath("E:/document/zj-utils/excel/写入excel" + "1" + ".xls");
// readExcel.setSheetValue(new String[] { "Sheet1" });
DatasKeySheets datasKeySheets = null;
// RE re = new RE();
// datasKeySheets = ExcelUtil.readExcel(readExcel,re);
datasKeySheets = ExcelUtil.readExcel(readExcel);
List<SheetDatas> sheetDatas = datasKeySheets.getSheetDatas();
for (SheetDatas datas : sheetDatas) {
// =======================
System.out.println("sheet:" + datas.getSheetIndex() + "\t\t" + datas.getSheetName() + "\t\t" + datas.getSheet());
// 循环sheet
// 获取某个sheet的行列数据
List<List<SheetData>> datasLst = datas.getRowsDataLst();
if (datasLst != null) {
// 循环某个sheet的行数据
for (List<SheetData> dataLst : datasLst) {
// 循环某个sheet的列数据
for (SheetData data : dataLst) {
if (data != null) {
System.out.print(data.getValue() + "\t\t");
}
}
System.out.println();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
------------------------------导出excel数据------------------------------
try { // 设置数据 for (int ii = 0; ii < 10; ii++) { ListsheetDatas = new ArrayList (); for (int k = 0; k < 10; k++) { // 所有行列数据对象 SheetDatas sheetData = new SheetDatas(); sheetData.setSheetName("sheet名." + k); sheetDatas.add(sheetData); // 所有行数据 List > rowsDataLst = new ArrayList
>(); // 设置所有行数据 sheetData.setRowsDataLst(rowsDataLst); // 所有列数据 List
columnsDataLst = null; // 所有单元格数据 SheetData data = null; // 实例化所有行列数据 for (int i = 0; i < 10000; i++) { // 设置第i行数据 columnsDataLst = new ArrayList (); rowsDataLst.add(columnsDataLst); // 添加第j行数据 for (int j = 0; j < 10; j++) { data = new SheetData(); if (j == 5) { data.setValue(i * j); } else { data.setValue("行" + i + "列" + j); } columnsDataLst.add(data); } } } // 导出excel设置 Excel excel = new Excel(); excel.setFilePath("E:/document/zj-utils/excel/写入excel" + ii + ".xls"); ExcelUtil.writeExcel(sheetDatas, excel); } } catch (Exception e) { e.printStackTrace(); }
ExcelReadUtil,
ExcelWriteUtil,
序列化表格| 限定符和类型 | 方法和说明 |
|---|---|
static org.apache.poi.ss.util.CellRangeAddress |
getMergedRegion(org.apache.poi.ss.usermodel.Sheet sheet,
int row,
int column)
已过时。
判断指定的单元格是否是合并单元格
|
static java.lang.Object |
readCellString(org.apache.poi.ss.usermodel.Cell cell)
已过时。
获取一个cell的数据类型
|
static java.lang.Object |
readCellValue(Excel excel,
java.util.Map<ConstantForEnum.CellValueKey,java.lang.Object> params)
已过时。
读取excel某个单元格值
|
static java.util.Map<ConstantForEnum.CellValueKey,java.lang.Integer> |
readCellValueIndex(Excel excel,
java.util.Map<ConstantForEnum.CellValueKey,java.lang.Object> params)
已过时。
读取excel某个单元格值的索引号
|
static DatasKeySheets |
readExcel(Excel excel)
已过时。
读取excel
|
static DatasKeySheets |
readExcel(Excel excel,
ExcelI excelI)
已过时。
读取excel
|
static java.util.List<java.lang.String> |
readExcelSheetNames(Excel excel)
已过时。
读取excel
|
static void |
readNormalData(Excel excel,
org.apache.poi.ss.usermodel.Sheet sheet,
SheetDatas datas,
ExcelI excelI)
已过时。
读取sheet行列集合(正常)
|
static void |
readTitleData(Excel excel,
org.apache.poi.ss.usermodel.Sheet sheet,
SheetDatas datas,
ExcelI excelI)
已过时。
读取sheet行列集合(有标题)
|
static void |
readTitleDataOld(Excel excel,
org.apache.poi.ss.usermodel.Sheet sheet,
SheetDatas datas,
ExcelI excelI)
已过时。
|
static void |
threadWriteTemplateExcel(ExcelTemplate excel)
已过时。
读取excel
|
static void |
threadWriteTemplateExcel(ExcelTemplate excel,
ExcelI excelI)
已过时。
读取excel
|
static void |
writeExcel(java.util.List<SheetDatas> sheetDatas,
Excel excel)
已过时。
|
static void |
writeExcel(java.util.List<SheetDatas> sheetDatas,
Excel excel,
ExcelI excelI)
已过时。
|
static void |
writeTemplateExcel(ExcelTemplate excel)
已过时。
读取excel
|
static void |
writeTemplateExcel(ExcelTemplate excel,
ExcelI excelI)
已过时。
读取excel
|
static void |
writeTemplateFile(ExcelTemplate excel)
已过时。
写文件
|
static boolean |
writeTemplateSheet(org.apache.poi.ss.usermodel.Sheet sheet,
ExcelTemplate excel,
ExcelI excelI)
已过时。
读取sheet行列集合
|
public static final DatasKeySheets readExcel(Excel excel) throws java.lang.Exception
excel - excel对象java.lang.Exceptionpublic static final java.util.List<java.lang.String> readExcelSheetNames(Excel excel) throws java.lang.Exception
excel - excel对象java.lang.Exceptionpublic static final DatasKeySheets readExcel(Excel excel, ExcelI excelI) throws java.lang.Exception
excel - excel对象excelI - excelI接口java.lang.Exceptionpublic static final void readTitleData(Excel excel, org.apache.poi.ss.usermodel.Sheet sheet, SheetDatas datas, ExcelI excelI) throws java.lang.Exception
sheet - datas - excelI - java.lang.Exception@Deprecated public static final void readTitleDataOld(Excel excel, org.apache.poi.ss.usermodel.Sheet sheet, SheetDatas datas, ExcelI excelI) throws java.lang.Exception
java.lang.Exceptionpublic static final void readNormalData(Excel excel, org.apache.poi.ss.usermodel.Sheet sheet, SheetDatas datas, ExcelI excelI) throws java.lang.Exception
sheet - datas - excelI - java.lang.Exception@Deprecated public static final void writeExcel(java.util.List<SheetDatas> sheetDatas, Excel excel) throws java.lang.Exception
sheetDatas - 所有行列数据对象excel - excel对象java.lang.ExceptionwriteTemplateExcel(ExcelTemplate)@Deprecated public static final void writeExcel(java.util.List<SheetDatas> sheetDatas, Excel excel, ExcelI excelI) throws java.lang.Exception
sheetDatas - 数据集合excel - 对象excelI - 接口java.lang.ExceptionwriteTemplateExcel(ExcelTemplate, ExcelI)public static final void writeTemplateExcel(ExcelTemplate excel) throws java.lang.Exception
excel - excel对象java.lang.Exceptionpublic static final void threadWriteTemplateExcel(ExcelTemplate excel) throws java.lang.Exception
excel - excel对象java.lang.Exceptionpublic static final void writeTemplateExcel(ExcelTemplate excel, ExcelI excelI) throws java.lang.Exception
excel - excel对象excelI - excelI接口java.lang.Exceptionpublic static final void threadWriteTemplateExcel(ExcelTemplate excel, ExcelI excelI) throws java.lang.Exception
excel - excel对象excelI - excelI接口java.lang.Exceptionpublic static final boolean writeTemplateSheet(org.apache.poi.ss.usermodel.Sheet sheet,
ExcelTemplate excel,
ExcelI excelI)
throws java.lang.Exception
sheet - excel - excelI - java.lang.Exceptionpublic static final java.util.Map<ConstantForEnum.CellValueKey,java.lang.Integer> readCellValueIndex(Excel excel, java.util.Map<ConstantForEnum.CellValueKey,java.lang.Object> params) throws java.lang.Exception
excel - excel对象params - 参数java.lang.Exceptionpublic static final java.lang.Object readCellValue(Excel excel, java.util.Map<ConstantForEnum.CellValueKey,java.lang.Object> params) throws java.lang.Exception
excel - excel对象params - 参数java.lang.Exceptionpublic static final void writeTemplateFile(ExcelTemplate excel) throws java.lang.Exception
java.lang.Exceptionpublic static final org.apache.poi.ss.util.CellRangeAddress getMergedRegion(org.apache.poi.ss.usermodel.Sheet sheet,
int row,
int column)
sheet - row - 行下标column - 列下标public static final java.lang.Object readCellString(org.apache.poi.ss.usermodel.Cell cell)
cell -