Package Writers

Source Code of Writers.XLSWriter

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Writers;

import Core.Data;
import Core.Result;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableCell;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

/**
*
* @author LauretHa
*/
public class XLSWriter extends FileWriter
{

    /**
     * Constructor for objects of class XLSWriter
     * @param data data to be written to file
     * @param result result to be written to file
     * @param outputFile output file to contain the data and results
     */
    public XLSWriter(Data data,Result result,File outputFile)
    {

        this.data = data;
        this.result = result;
        this.outputFile = outputFile;

    }

    @Override
    public void writeAll() throws FileNotFoundException, IOException{
        WritableWorkbook workbook = Workbook.createWorkbook(outputFile);
        WritableSheet sheet = workbook.createSheet("results", 0);

        try {
            sheet.addCell(new Label(0, 0, "NUMBER OF PILE ELEMENTS"));
            sheet.addCell(new Label(0, 1, "PILE LENGTH (m)"));
            sheet.addCell(new Label(0, 2, "PILE EI (KN M²)"));
            sheet.addCell(new Label(0, 3, "DIAMETER OF PILE (m)"));
            sheet.addCell(new Label(0, 4, "NUMBER OF INCREMENTAL SOIL DISPLACEMENTS"));
           
            sheet.addCell(new jxl.write.Number(5, 0, data.getNumOfElements()));
            sheet.addCell(new jxl.write.Number(5, 1, data.getPileLength()));
            sheet.addCell(new jxl.write.Number(5, 2, data.getEI()));
            sheet.addCell(new jxl.write.Number(5, 3, data.getPileDiameter()));
            sheet.addCell(new jxl.write.Number(5, 4, data.getNumOfPiles()));

            sheet.addCell(new Label(0, 6, "DEPTH COORDINATES OF PILE NODES (M)"));
            int currentRow = 7;
            int elementCounter =0;
            for(int i=0;i<=(data.getNumOfElements()/5);i++){
                int col=0;
                for(int j=i*5;j<=(i*5)+4;j++){
                  if(elementCounter<=data.getNumOfElements()){
                      sheet.addCell(new jxl.write.Number(col,currentRow,data.getPileNodeCoordinate(j)));
                      col++;
                   }

                   elementCounter++;
             }
                   currentRow++;
            }
            sheet.addCell(new Label(0, currentRow+1, "MODULUS OF SUBGRADE REACTION OF SOIL (KN/M PER M)  AT EACH NODE"));
            currentRow+=2;
            elementCounter =0;
            for(int i=0;i<=(data.getNumOfElements()/5);i++){
                int col=0;
                for(int j=i*5;j<=(i*5)+4;j++){
                  if(elementCounter<=data.getNumOfElements()){
                      sheet.addCell(new jxl.write.Number(col,currentRow,data.getModOfSubgradeReaction(j)));
                      col++;
                   }

                   elementCounter++;
             }
                   currentRow++;
            }
            sheet.addCell(new Label(0, currentRow+1, "LATERAL SOIL MOVEMENTS AT VARIOUS DEPTHS (M)"));
            currentRow+=2;
            elementCounter =0;
            for(int i=0;i<=(data.getNumOfElements()/5);i++){
                int col=0;
                for(int j=i*5;j<=(i*5)+4;j++){
                  if(elementCounter<=data.getNumOfElements()){
                      sheet.addCell(new jxl.write.Number(col,currentRow,data.getLateralSoilMovement(j)));
                      col++;
                   }

                   elementCounter++;
             }
                   currentRow++;
            }

            sheet.addCell(new Label(0, currentRow+1, "LIMIT SOIL PRESSURE (KN/M²)"));
            currentRow+=2;
            elementCounter =0;
            for(int i=0;i<=(data.getNumOfElements()/5);i++){
                int col=0;
                for(int j=i*5;j<=(i*5)+4;j++){
                  if(elementCounter<=data.getNumOfElements()){
                      sheet.addCell(new jxl.write.Number(col,currentRow,data.getLimitSoilPressure(j)));
                      col++;
                   }

                   elementCounter++;
             }
                   currentRow++;
            }
            currentRow++;
            sheet.addCell(new Label(0,currentRow,"INCREMENT NO 1"));
            currentRow++;
            sheet.addCell(new Label(0,currentRow,"NUMBER OF ITERATIONS TO CONVERGE"));
            sheet.addCell(new jxl.write.Number(1, currentRow, result.getNumOfItrForConv()));
            currentRow+=2;
            sheet.addCell(new Label(0,currentRow,"NODE"));
            sheet.addCell(new Label(1,currentRow,"DEPTH (m)"));
            sheet.addCell(new Label(2,currentRow,"SOIL MOVEMENT (mm)"));
            sheet.addCell(new Label(3,currentRow,"SOIL PRESSURE (kPa)"));
            sheet.addCell(new Label(4,currentRow,"ABS LIMIT PRESSURE (kPa)"));
            currentRow++;
            for(int i=0;i<data.getNumOfElements()+1;i++){
                sheet.addCell(new jxl.write.Number(0, currentRow, i+1));
                sheet.addCell(new jxl.write.Number(1, currentRow, data.getPileNodeCoordinate(i)));
                sheet.addCell(new jxl.write.Number(2, currentRow, result.getSoilMovement(i)*1000));
                sheet.addCell(new jxl.write.Number(3, currentRow, result.getSoilPressure(i)));
                sheet.addCell(new jxl.write.Number(4, currentRow, result.getLimitPressure(i)));
                currentRow++;
            }
            currentRow+=2;
            sheet.addCell(new Label(0,currentRow,"NODE"));
            sheet.addCell(new Label(1,currentRow,"DEPTH (m)"));
            sheet.addCell(new Label(2,currentRow,"PILE DISPLACEMENT (mm)"));
            sheet.addCell(new Label(3,currentRow,"ROTATION (rad)"));
            sheet.addCell(new Label(4,currentRow,"BENDM (KNm)"));
            sheet.addCell(new Label(5,currentRow,"SHEAR FORCE (KN)"));
            currentRow++;
            for(int i=0;i<data.getNumOfElements()+1;i++){
                sheet.addCell(new jxl.write.Number(0, currentRow, i+1));
                sheet.addCell(new jxl.write.Number(1, currentRow, data.getPileNodeCoordinate(i)));
                sheet.addCell(new jxl.write.Number(2, currentRow, result.getDisplacement(i)*1000));
                sheet.addCell(new jxl.write.Number(3, currentRow, result.getRotation(i)));
                sheet.addCell(new jxl.write.Number(4, currentRow, result.getBendingMoment(i)));
                sheet.addCell(new jxl.write.Number(5, currentRow, result.getShearForce(i)));
                currentRow++;
            }

           
           
        } catch (WriteException ex) {
            Logger.getLogger(XLSWriter.class.getName()).log(Level.SEVERE, null, ex);
        }

        workbook.write();
        try {
            workbook.close();
        } catch (WriteException ex) {
            Logger.getLogger(XLSWriter.class.getName()).log(Level.SEVERE, null, ex);
        }



    }

}
TOP

Related Classes of Writers.XLSWriter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.