Facebook
From Gracious Wigeon, 7 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 397
  1. package com.mysite.inmarsat;
  2.  
  3. import java.io.*;
  4. import org.apache.poi.hssf.usermodel.HSSFSheet;
  5. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  6. import org.apache.poi.hssf.usermodel.HSSFRow;
  7. import org.apache.poi.hssf.usermodel.HSSFCell;
  8.  
  9. /**
  10.  * Created by gmlynarczy001 on 2016-09-14.
  11.  */
  12. public class Xwriter {
  13.  
  14.     String filename = "INFO.xls";
  15.     HSSFWorkbook workbook = new HSSFWorkbook();
  16.     HSSFSheet uat = workbook.createSheet("UAT");
  17.     HSSFSheet dht = workbook.createSheet("DHT");
  18.     int n = 0;
  19.  
  20.         public void saveExcelMC(String mc){
  21.             try {
  22.  
  23.                 if (EnvAndDP.DP.equals("SHARE")) {
  24.                     n = 1;
  25.                 } else if (EnvAndDP.DP.equals("1090")) {
  26.                     n = 2;
  27.                 } else if (EnvAndDP.DP.equals("1180")) {
  28.                     n = 3;
  29.                 }
  30.  
  31.                 if (EnvAndDP.ENV.equals("UAT")) {
  32.                     HSSFRow head = uat.createRow((short) 0);
  33.                     head.createCell(0).setCellValue("TYPE");
  34.                     head.createCell(1).setCellValue("SHARE");
  35.                     head.createCell(2).setCellValue("1090X");
  36.                     head.createCell(3).setCellValue("1180X");
  37.  
  38.                     HSSFRow rowMC = uat.createRow((short) 1);
  39.                     rowMC.createCell(0).setCellValue("Major Corporate");
  40.                     rowMC.createCell(n).setCellValue(mc);
  41.  
  42.                 } else if (EnvAndDP.ENV.equals("DHT")) {
  43.                     HSSFRow head = dht.createRow((short) 0);
  44.                     head.createCell(0).setCellValue("TYPE");
  45.                     head.createCell(1).setCellValue("SHARE");
  46.                     head.createCell(2).setCellValue("1090X");
  47.                     head.createCell(3).setCellValue("1180X");
  48.  
  49.                     HSSFRow rowMC = dht.createRow((short) 1);
  50.                     rowMC.createCell(0).setCellValue("Major Corporate");
  51.                     rowMC.createCell(n).setCellValue(mc);
  52.                 }
  53.  
  54.                 FileOutputStream fileOut = new FileOutputStream(filename);
  55.                 workbook.write(fileOut);
  56.                 fileOut.close();
  57.  
  58.             }catch (IOException e){
  59.                 e.printStackTrace();
  60.             }
  61.         }
  62.         public void saveExcelVess(String vess){
  63.             try {
  64.  
  65.                 if (EnvAndDP.DP.equals("SHARE")) {
  66.                     n = 1;
  67.                 } else if (EnvAndDP.DP.equals("1090")) {
  68.                     n = 2;
  69.                 } else if (EnvAndDP.DP.equals("1180")) {
  70.                     n = 3;
  71.                 }
  72.  
  73.                 if (EnvAndDP.ENV.equals("UAT")) {
  74.                     HSSFRow head = uat.createRow((short) 0);
  75.                     head.createCell(0).setCellValue("TYPE");
  76.                     head.createCell(1).setCellValue("SHARE");
  77.                     head.createCell(2).setCellValue("1090X");
  78.                     head.createCell(3).setCellValue("1180X");
  79.  
  80.                     HSSFRow rowVess = uat.createRow((short) 2);
  81.                     rowVess.createCell(0).setCellValue("Vessel");
  82.                     rowVess.createCell(n).setCellValue(vess);
  83.  
  84.                 } else if (EnvAndDP.ENV.equals("DHT")) {
  85.                     HSSFRow head = dht.createRow((short) 0);
  86.                     head.createCell(0).setCellValue("TYPE");
  87.                     head.createCell(1).setCellValue("SHARE");
  88.                     head.createCell(2).setCellValue("1090X");
  89.                     head.createCell(3).setCellValue("1180X");
  90.  
  91.                     HSSFRow rowVess = dht.createRow((short) 2);
  92.                     rowVess.createCell(0).setCellValue("Vessel");
  93.                     rowVess.createCell(n).setCellValue(vess);
  94.                 }
  95.  
  96.                 FileOutputStream fileOut = new FileOutputStream(filename);
  97.                 workbook.write(fileOut);
  98.                 fileOut.close();
  99.  
  100.             }catch (IOException e){
  101.                 e.printStackTrace();
  102.             }
  103.         }
  104. }

Replies to Untitled rss

Title Name Language When
Re: Untitled Edgy Butterfly java 7 Years ago.