Java Operations Excel Method _java

Source: Internet
Author: User

The example in this article describes the Java Operations method for Excel. Share to everyone for your reference. as follows:

Writableworkbook workbook = Workbook.createworkbook (new File ("D:\\output.xls")); 
 Writablesheet sheet = workbook.createsheet ("Project Briefing", 0); 
 Style Writablefont Sonti18font = new Writablefont (Writablefont.createfont ("XXFarEastFont-Arial"), 18,writablefont.bold); 
 Writablefont Sonti12font = new Writablefont (Writablefont.createfont ("XXFarEastFont-Arial"), 12,writablefont.bold); 
 Writablefont sonti12fontnobold = new Writablefont (Writablefont.createfont ("XXFarEastFont-Arial"), 12,writablefont.no_bold); 
 Writablecellformat font18subject = new Writablecellformat (Sonti18font); 
 Writablecellformat font12subject = new Writablecellformat (Sonti12font); 
 Writablecellformat font12subjectnobold = new Writablecellformat (sonti12fontnobold); 
 Font18subject.setalignment (Jxl.format.Alignment.CENTRE);  
 Font18subject.setverticalalignment (Jxl.format.VerticalAlignment.CENTRE);  
 Font18subject.setborder (Jxl.format.border.all,jxl.format.borderlinestyle.thin); 
 Font12subject.setalignment (Jxl.format.Alignment.LEFT); Font12subject.setverticalalignmENT (Jxl.format.VerticalAlignment.CENTRE); 
 Font12subject.setborder (Jxl.format.border.all,jxl.format.borderlinestyle.thin); 
 Font12subjectnobold.setalignment (Jxl.format.Alignment.LEFT);  
 Font12subjectnobold.setverticalalignment (Jxl.format.VerticalAlignment.CENTRE); 
 Font12subjectnobold.setborder (Jxl.format.border.all,jxl.format.borderlinestyle.thin); 
 Style end//Project profile information Sheet.addcell (new Label (0, 0, projreportparam.getproj_name () + "project Briefing", Font18subject)); 
 Sheet.mergecells (0, 0, 5, 0); 
 Sheet.addcell (New Label (0,1, "Item number", Font12subject)); 
 Sheet.addcell (New Label (1,1,projreportparam.getproj_code (), font12subjectnobold)); 
 Sheet.addcell (New Label (2,1, "project Manager", Font12subject)); 
 Sheet.addcell (New Label (3,1,projreportparam.getemp_name (), font12subjectnobold)); 
 Sheet.addcell (New Label (4,1, "project Department", Font12subject)); 
 Sheet.addcell (New Label (5,1,projreportparam.getdept_name (), font12subjectnobold)); 
 Sheet.addcell (New Label (0,2, "planned cost incurred", Font12subject)); Sheet.addcell (New Label 1, 2,Projreportparam.getplan_cost (), font12subjectnobold)); 
 Sheet.addcell (New Label (2,2, "actual incurred cost", font12subject)); 
 Sheet.addcell (New Label (3,2,projreportparam.getactual_cost (), font12subjectnobold)); 
 Sheet.addcell (New Label (0,3, "Project Profile", Font12subject)); 
 Sheet.addcell (New Label (1,3,projreportparam.getproj_desc (), font12subjectnobold)); 
 Sheet.mergecells (1, 3, 5, 3); 
 Project profile information end//Milestone Sheet.addcell (new Label (0,5, "milestone", Font18subject)); 
 Sheet.mergecells (0, 5, 5, 5); 
 Sheet.addcell (New Label (0,6, "stage name", Font12subject)); 
 Sheet.addcell (New Label (1, 6, "Task Name", Font12subject)); 
 Sheet.addcell (New Label (2,6, "Implementing Person", Font12subject)); 
 Sheet.addcell (New Label (3,6, "plan start and End time", Font12subject)); 
 Sheet.addcell (New Label (4,6, "actual starting and Ending Time", Font12subject)); 
 Sheet.addcell (New Label (5,6, "state", Font12subject)); int i = 7;//line for (Projreportparamminfo projReportParamMInfo:projReportParam.getProjReportParamMInfoList ()) {SHEET.A Ddcell (New Label (0,i,projreportparamminfo.getpharse_name (), Font12subjectnobold)); 
  Sheet.addcell (New Label (1,i,projreportparamminfo.gettask_item (), font12subjectnobold)); 
  Sheet.addcell (New Label (2,i,projreportparamminfo.getemp_name (), font12subjectnobold)); Sheet.addcell (New Label (3,i,utils.formatdate (PROJREPORTPARAMMINFO.GETTASK_PLAN_SD ()) + "/" + utils.formatdate ( 
  PROJREPORTPARAMMINFO.GETTASK_PLAN_FD ()), font12subjectnobold); Sheet.addcell (New Label (4,i,utils.formatdate (PROJREPORTPARAMMINFO.GETTASK_ACTUAL_SD ()) + "/" + utils.formatdate ( 
  PROJREPORTPARAMMINFO.GETTASK_ACTUAL_FD ()), font12subjectnobold); 
  Sheet.addcell (New Label (5,i,projreportparamminfo.gettask_state (), font12subjectnobold)); 
 i++; 
 }//Milestone end//project team members and stakeholders int j = 1+i;//line Sheet.addcell (new Label (0,J, project team member and Stakeholder, Font18subject)); 
 Sheet.mergecells (0, J, 5, J); 
 Sheet.addcell (New Label (0,j+1, "serial number", Font12subject)); 
 Sheet.addcell (New Label (1,j+1, "name", Font12subject)); 
 Sheet.addcell (New Label (2,j+1, "role", Font12subject)); Sheet.addcell (New Label (3,j+1, "Enter project group Time", Font12subject)); 
 Sheet.addcell (New Label (4,j+1, "Leave project group Time", Font12subject)); 
 Sheet.addcell (New Label (5,j+1, "Cumulative work", font12subject)); int m = 1;//ordinal int n = j+2;//line for (Projreportparamhrinfo ProjReportParamHRInfo:projReportParam.getProjReportParamHRI 
  Nfolist ()) {Sheet.addcell (new Label (0,n,m+ "", Font12subjectnobold)); 
  Sheet.addcell (New Label (1,n,projreportparamhrinfo.getemp_name (), font12subjectnobold)); 
  Sheet.addcell (New Label (2,n,projreportparamhrinfo.getrole_name (), font12subjectnobold)); 
  Sheet.addcell (New Label (3,n,utils.formatdate (Projreportparamhrinfo.gethr_start_date ()), font12subjectnobold)); 
  Sheet.addcell (New Label (4,n,utils.formatdate (Projreportparamhrinfo.gethr_release_date ()), font12subjectnobold)); 
  Sheet.addcell (New Label (5,n,projreportparamhrinfo.gettotal_manhour (), font12subjectnobold)); 
  m++; 
 n++; //project team members and stakeholders end//the current work content int k = n + 1;//row Sheet.addcell (0,k, the current work content ("+startdate+" to "+enddate+") ", Font1 
 8Subject)); Sheet.mergecells (0, K, 6, K); 
 Sheet.addcell (New Label (0,k+1, "task number", Font12subject)); 
 Sheet.addcell (New Label (1,k+1, "Task Name", Font12subject)); 
 Sheet.addcell (New Label (2,k+1, "plan start and End time", Font12subject)); 
 Sheet.addcell (New Label (3,k+1, "actual starting and Ending Time", Font12subject)); 
 Sheet.addcell (New Label (4,k+1, "planned work", Font12subject)); 
 Sheet.addcell (New Label (5,k+1, "Actual Work", font12subject)); 
 Sheet.addcell (New Label (6,k+1, "enforcement officer", Font12subject)); int p = k + 2;//line for (Projreportparamtaskinfo ProjReportParamTaskInfo:projReportParam.getThisProjReportParamTaskInfoL 
  IST ()) {Sheet.addcell (New Label (0,p,projreportparamtaskinfo.gettask_code (), font12subjectnobold)); 
  Sheet.addcell (New Label (1,p,projreportparamtaskinfo.gettask_item (), font12subjectnobold)); Sheet.addcell (New Label (2,p,utils.formatdate (PROJREPORTPARAMTASKINFO.GETTASK_PLAN_SD ()) + "/" + utils.formatdate ( 
  PROJREPORTPARAMTASKINFO.GETTASK_PLAN_FD ()), font12subjectnobold); Sheet.addcell (New Label (3,p,utils.formatdate (PROJREPORTPARAMTASKINFO.GETTASK_ACTUAL_SD ()) + "/" + Utils.formatdate (PROJREPORTPARAMTASKINFO.GETTASK_ACTUAL_FD ()), font12subjectnobold); 
  Sheet.addcell (New Label (4,p,projreportparamtaskinfo.gettask_plan_manhour (), font12subjectnobold)); 
  Sheet.addcell (New Label (5,p,projreportparamtaskinfo.gettask_actual_manhour (), font12subjectnobold)); 
  Sheet.addcell (New Label (6,p,projreportparamtaskinfo.getplan_emp_name (), font12subjectnobold)); 
 p++; 
 The current work content end//next week work content int q = p + 1;//line Sheet.addcell (new Label (0,q, "work next week", Font18subject)); 
 Sheet.mergecells (0, Q, 5, q); 
 Sheet.addcell (New Label (0,q+1, "task number", Font12subject)); 
 Sheet.addcell (New Label (1,q+1, "Task Name", Font12subject)); 
 Sheet.addcell (New Label (2,q+1, "scheduled start Time", Font12subject)); 
 Sheet.addcell (New Label (3,q+1, "Schedule End Time", Font12subject)); 
 Sheet.addcell (New Label (4,q+1, "planned work", Font12subject)); 
 Sheet.addcell (New Label (5,q+1, "enforcement officer", Font12subject)); 
 int r = q + 2; For (Projreportparamtaskinfo projReportParamTaskInfo:projReportParam.getNextProjReportParamTaskInfoList ()) { 
  Sheet.addcell (New Label (0,r,projreportparamtaskinfo.gettask_code (), font12subjectnobold)); 
  Sheet.addcell (New Label (1,r,projreportparamtaskinfo.gettask_item (), font12subjectnobold)); 
  Sheet.addcell (New Label (2,r,utils.formatdate (PROJREPORTPARAMTASKINFO.GETTASK_PLAN_SD ()), font12subjectnobold)); 
  Sheet.addcell (New Label (3,r,utils.formatdate (PROJREPORTPARAMTASKINFO.GETTASK_PLAN_FD ()), font12subjectnobold)); 
  Sheet.addcell (New Label (4,r,projreportparamtaskinfo.gettask_plan_manhour (), font12subjectnobold)); 
  Sheet.addcell (New Label (5,r,projreportparamtaskinfo.getplan_emp_name (), font12subjectnobold)); 
 r++; 
 }//next week work content end//project problems and solutions int s = r + 1;//line Sheet.addcell (new Label (0,s, "problem and resolution of project", Font18subject)); 
 Sheet.mergecells (0, S, 8, s); 
 Sheet.addcell (New Label (0,s+1, "date of identification", Font12subject)); 
 Sheet.addcell (New Label (1,s+1, "Problem description", font12subject)); 
 Sheet.addcell (New Label (2,s+1, "risk-subordinate", Font12subject)); 
 Sheet.addcell (New Label (3,s+1, "Resolution", font12subject)); Sheet.aDdcell (New Label (4,s+1, "solution person", font12subject)); 
 Sheet.addcell (New Label (5,s+1, "scheduled start Time", Font12subject)); 
 Sheet.addcell (New Label (6,s+1, "Planned finish Time", Font12subject)); 
 Sheet.addcell (New Label (7,s+1, "problem state", font12subject)); 
 Sheet.addcell (New Label (8,s+1, "Summary", Font12subject)); int t = s + 2;//line for (Projreportparamriskinfo projReportParamRiskInfo:projReportParam.getProjReportParamRiskInfoList ( 
  ) {Sheet.addcell (New Label (0,t,utils.formatdate (Projreportparamriskinfo.getsts_date ()), font12subjectnobold)); 
  Sheet.addcell (New Label (1,t,projreportparamriskinfo.getproj_issue_item (), font12subjectnobold)); 
  Sheet.addcell (New Label (2,t,projreportparamriskinfo.getproj_risk_item (), font12subjectnobold)); 
  Sheet.addcell (New Label (3,t,projreportparamriskinfo.getissue_resolve_method (), font12subjectnobold)); 
  Sheet.addcell (New Label (4,t,projreportparamriskinfo.getissue_resolve_emp (), font12subjectnobold)); Sheet.addcell (New Label (5,t,utils.formatdate Projreportparamriskinfo.getissue_plan_datE ()), font12subjectnobold); Sheet.addcell (New Label (6,t,utils.formatdate (Projreportparamriskinfo.getissue_actual_date ()), 
  Font12subjectnobold)); 
  Sheet.addcell (New Label (7,t,projreportparamriskinfo.getissue_state (), font12subjectnobold)); 
  Sheet.addcell (New Label (8,t,projreportparamriskinfo.getissue_summarize (), font12subjectnobold)); 
 t++; 
 }//Project existing problems and Solutions end workbook.write (); 
Workbook.close ();

 Program to generate project briefs

I hope this article will help you with your Java programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.