XSSFWorkbook xwb = new XSSFWorkbook(excel);
XSSFSheet sheet = xwb.getSheetAt(0);
for (int i = sheet.getFirstRowNum() + 1; i <= sheet.getPhysicalNumberOfRows(); i++) {
XSSFRow row = sheet.getRow(i);
if (row != null) {
//metaID
XSSFCell cell0 = row.getCell(0);
if (null == cell0) {
throw new Exception("唯一标识MetaID不能为空!");
}
// 中文标题
XSSFCell cell1 = row.getCell(1);
if (null == cell1) {
throw new Exception("标题不能为空!");
}
// StatutesTitle
XSSFCell cell2 = row.getCell(2);
if (null == cell2) {
throw new Exception("StatutesTitle不能为空!");
}
//StatutesTitle
XSSFCell cell3 = row.getCell(3);
if (null == cell3) {
throw new Exception("法律部门不能为空!");
}
//LegalDepartment
XSSFCell cell4 = row.getCell(4);
if (null == cell4) {
throw new Exception("LegalDepartment不能为空!");
}
//发布部门英文
XSSFCell cell5 = row.getCell(5);
if (null == cell5) {
throw new Exception("发布部门不能为空!");
}
//IssuingDepartment
XSSFCell cell6 = row.getCell(6);
if (null == cell6) {
throw new Exception("IssuingDepartment不能为空!");
}
//发布机构类型
XSSFCell cell7 = row.getCell(7);
if (null == cell7) {
throw new Exception("发布机构类型不能为空!");
}
//IssuingOrganizationType
XSSFCell cell8 = row.getCell(8);
if (null == cell8) {
throw new Exception("IssuingOrganizationType不能为空!");
}
//批准部门
XSSFCell cell9 = row.getCell(9);
//ApprovalDepartment
XSSFCell cell10 = row.getCell(10);
//通过/批准日期
XSSFCell cell11 = row.getCell(11);
//ApprovalDate
XSSFCell cell12 = row.getCell(12);
//发布文号
//TODO 有则必填??
XSSFCell cell13 = row.getCell(13);
//DispatchNo
XSSFCell cell14 = row.getCell(14);
//公布/发布日期
XSSFCell cell15 = row.getCell(15);
if (null == cell15) {
throw new Exception("公布/发布日期不能为空!");
}
//ReleaseDate
XSSFCell cell16 = row.getCell(16);
if (null == cell16) {
throw new Exception("ReleaseDate不能为空!");
}
//施行日期
XSSFCell cell17 = row.getCell(17);
if (null == cell17) {
throw new Exception("施行日期不能为空!");
}
//ImplementationDate
XSSFCell cell18 = row.getCell(18);
if (null == cell18) {
throw new Exception("ImplementationDate不能为空!");
}
//废止日期
XSSFCell cell19 = row.getCell(19);
//AbolitionDate
XSSFCell cell20 = row.getCell(20);
//历史沿革
XSSFCell cell21 = row.getCell(21);
//HistoricalDevelopment
XSSFCell cell22 = row.getCell(22);
//时效性
XSSFCell cell23 = row.getCell(23);
if (null == cell23) {
throw new Exception("时效性不能为空!");
}
//Timeliness
XSSFCell cell24 = row.getCell(24);
if (null == cell24) {
throw new Exception("Timeliness不能为空!");
}
//效力级别
XSSFCell cell25 = row.getCell(25);
if (null == cell25) {
throw new Exception("效力级别不能为空!");
}
//EffectivenessGrade
XSSFCell cell26 = row.getCell(26);
if (null == cell26) {
throw new Exception("EffectivenessGrade不能为空!");
}
//来源
XSSFCell cell27 = row.getCell(27);
if (null == cell27) {
throw new Exception("来源不能为空!");
}
//SourceName
XSSFCell cell28 = row.getCell(28);
if (null == cell28) {
throw new Exception("SourceName不能为空!");
}
//地域
XSSFCell cell29 = row.getCell(29);
if (null == cell29) {
throw new Exception("地域不能为空!");
}
//Areas
XSSFCell cell30 = row.getCell(30);
if (null == cell30) {
throw new Exception("Areas不能为空!");
}
//年度
XSSFCell cell31 = row.getCell(31);
if (null == cell31) {
throw new Exception("年度不能为空!");
}
//Year
XSSFCell cell32 = row.getCell(32);
if (null == cell32) {
throw new Exception("Year不能为空!");
}
//主题分类
XSSFCell cell33 = row.getCell(33);
if (null == cell33) {
throw new Exception("主题分类不能为空!");
}
//IndustryClassification
XSSFCell cell34 = row.getCell(34);
if (null == cell34) {
throw new Exception("IndustryClassification不能为空!");
}
//学科分类
XSSFCell cell35 = row.getCell(35);
if (null == cell35) {
throw new Exception("学科分类不能为空!");
}
//SubjectCategory
XSSFCell cell36 = row.getCell(36);
if (null == cell36) {
throw new Exception("SubjectCategory不能为空!");
}
//中图法分类
XSSFCell cell37 = row.getCell(37);
if (null == cell37) {
throw new Exception("中图法分类不能为空!");
}
//CLC
XSSFCell cell38 = row.getCell(38);
if (null == cell38) {
throw new Exception("CLC不能为空!");
}
//案由
XSSFCell cell39 = row.getCell(39);
//CauseOfAction
XSSFCell cell40 = row.getCell(40);
//程序
XSSFCell cell41 = row.getCell(41);
if (null == cell41) {
throw new Exception("程序不能为空!");
}
//Procedure
XSSFCell cell42 = row.getCell(42);
if (null == cell42) {
throw new Exception("Procedure不能为空!");
}
//编辑提示
XSSFCell cell43 = row.getCell(43);
//EditPrompt
XSSFCell cell44 = row.getCell(44);
//字数
XSSFCell cell45 = row.getCell(45);
//Words
XSSFCell cell46 = row.getCell(46);
//试读比例(字数)
XSSFCell cell47 = row.getCell(47);
if (null == cell47) {
throw new Exception("试读比例(字数)不能为空!");
}
//Previews
XSSFCell cell48 = row.getCell(48);
if (null == cell48) {
throw new Exception("Previews不能为空!");
}
//文件路径
XSSFCell cell49 = row.getCell(49);
if (null == cell49) {
throw new Exception("文件路径不能为空!");
}
//PathFile
XSSFCell cell50 = row.getCell(50);
if (null == cell50) {
throw new Exception("PathFile不能为空!");
}
//资源类型
XSSFCell cell51 = row.getCell(51);
if (null == cell51) {
throw new Exception("资源类型不能为空!");
}
//ResourceType
XSSFCell cell52 = row.getCell(52);
if (null == cell52) {
throw new Exception("ResourceType不能为空!");
}
//价格
XSSFCell cell53 = row.getCell(53);
if (null == cell53) {
throw new Exception("价格不能为空!");
}
//Eprice
XSSFCell cell54 = row.getCell(54);
if (null == cell54) {
throw new Exception("Eprice不能为空!");
}
String metaID = cell0.toString();
String statutesTitle = cell1.toString();
String legalDepartment = cell3.toString();
String issuingDepartment = cell5.toString();
String issuingOrganizationType = cell7.toString();
String approvalDepartment = cell9.toString();
String approvalDepartmentEn = cell10.toString();
String approvalDate = cell11.toString();
String approvalDateEn = cell12.toString();
String dispatchNo = cell13.toString();
String dispatchNoEn = cell14.toString();
String releaseDate = cell15.toString();
String releaseDateEn = cell16.toString();
String implementationDate = cell17.toString();
String implementationDateEn = cell18.toString();
String abolitionDate = "";
String abolitionDateEn = "";
if(cell19 != null){
abolitionDate = cell19.toString();
}
if(cell20 != null){
abolitionDateEn = cell20.toString();
}
String historicalDevelopment = "";
String historicalDevelopmentEn = "";
if(cell21!= null){
historicalDevelopment = cell21.toString();
}
if(cell22 != null){
historicalDevelopmentEn = cell22.toString();
}
String timeliness = cell23.toString();
String effectivenessGrade = cell25.toString();
String sourceName = "";
String sourceNameEn = "";
if(cell25 != null){
sourceName = cell25.toString();
}
if(cell26 != null){
sourceNameEn = cell26.toString();
}
String areas = cell27.toString();
String year = cell29.toString();
String subjectClassify = cell31.toString();
String industryClassification = cell33.toString();
String subjectCategory = cell35.toString();
String clc = cell37.toString();
String causeOfAction = "";
String causeOfActionEn = "";
if(cell39 != null){
causeOfAction = cell39.toString();
}
if(cell40 != null){
causeOfActionEn = cell40.toString();
}
String procedure = cell41.toString();
String editPrompt = "";
String editPromptEn = "";
if(cell43 != null){
editPrompt = cell43.toString();
}
if(cell44 != null){
editPromptEn = cell44.toString();
}
String words = "";
String wordsEn = "";
if(cell45 != null){
words = cell45.toString();
}
if(cell46 != null){
wordsEn = cell46.toString();
}
String preViews = cell47.toString();
String pathFile = cell49.toString();
String resourceType = cell51.toString();
String eprice = cell53.toString();
String epriceEn = cell54.toString();
//给入库赋值
storage.setProductMetaId(metaID);
storage.setProductTitle(statutesTitle);
storage.setProductTitleEn(statutesTitle);
storage.setProductIssuingDepart(issuingDepartment);
storage.setProductIssuingDepartEn(issuingDepartment);
storage.setProductLegalDepartment(legalDepartment);
storage.setProductLegalDepartmentEn(legalDepartment);
storage.setProductIssuingOType(issuingOrganizationType);
storage.setProductIssuingOTypeEn(issuingOrganizationType);
storage.setProductApprovalDepart(approvalDepartment);
storage.setProductApprovalDeparttEn(approvalDepartmentEn);
storage.setProductApprovalDate(approvalDate);
storage.setProductApprovalDateEn(approvalDateEn);
storage.setProductDispatchNo(dispatchNo);
storage.setProductDispatchNoEn(dispatchNoEn);
storage.setProductReleaseDate(releaseDate);
storage.setProductReleaseDateEn(releaseDateEn);
storage.setProductImplementDate(implementationDate);
storage.setProductImplementDateEn(implementationDateEn);
storage.setProductAbolitionDate(abolitionDate);
storage.setProductAbolitionDateEn(abolitionDateEn);
storage.setProductHistoricalDevelop(historicalDevelopment);
storage.setProductHistoricalDevelopEn(historicalDevelopmentEn);
storage.setProductTimeliness(timeliness);
storage.setProductTimelinessEn(timeliness);
storage.setProductEffectivenessGrade(effectivenessGrade);
storage.setProductEffectivenessGradeEn(effectivenessGrade);
storage.setProductSourceName(sourceName);
storage.setProductSourceNameEn(sourceNameEn);
storage.setProductAreas(areas);
storage.setProductAreasEn(areas);
storage.setProductYear(year);
storage.setProductYearEn(year);
storage.setProductSubjectClass(subjectClassify);
storage.setProductSubjectClassEn(subjectClassify);
storage.setProductIndustryClassifica(industryClassification);
storage.setProductIndustryClassificaEn(industryClassification);
storage.setProductSubjectCategory(subjectCategory);
storage.setProductSubjectCategoryEn(subjectCategory);
storage.setProductCLC(clc);
storage.setProductCLCEn(clc);
storage.setProductCauseOfAction(causeOfAction);
storage.setProductCauseOfActionEn(causeOfActionEn);
storage.setProductProcedure(procedure);
storage.setProductProcedureEn(procedure);
storage.setProductEditPrompt(editPrompt);
storage.setProductEditPromptEn(editPromptEn);
storage.setProductWords(words);
storage.setProductWordsEn(wordsEn);
storage.setProductPreviews(preViews);
storage.setProductPreviewsEn(preViews);
storage.setProductPathFile(pathFile);
storage.setProductPathFileEn(pathFile);
storage.setProductResourceType(resourceType);
storage.setProductResourceTypeEn(resourceType);
storage.setProductEprice(eprice);
storage.setProductEpriceEn(epriceEn);
this.save(storage);
}
}
追问请问这是?做什么的
本回答被网友采纳