Errors in custom java action (generating excel file using HSSFWorkbook) while upgrading the application from 6.10.4 to 6.10.18 version. - Mendix Forum

Errors in custom java action (generating excel file using HSSFWorkbook) while upgrading the application from 6.10.4 to 6.10.18 version.

0

Hello community,

I have an application build with 6.10.4 version modeler and I have one custom java action, which will generates an excel file for me using HSSFWorkbook. Now, I am trying to upgrade my application to 6.10.18 version. In this process, I got some errors in my custom java action related to HSSFWorkbook. How can I resolve them. Please see the below error


An error has occurred while handling the request. [User 'MxAdmin' with session id '40dcbbde-0dc9-4aef-970a-8279e58d0d7a' and roles 'Administrator']

--------

com.mendix.modules.microflowengine.MicroflowException: com.mendix.core.CoreRuntimeException: An error occurred while instantiating action 'Export_InquirySummaryLogs'
    at Texisle.MF_GenerateQuoteSummaryReport (JavaAction : 'Export_InquirySummaryLogs')

Advanced stacktrace:
    at com.mendix.modules.microflowengine.MicroflowUtil.processException(MicroflowUtil.java:143)

Caused by: com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: An error occurred while instantiating action 'Export_InquirySummaryLogs'
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:504)

Caused by: com.mendix.core.CoreRuntimeException: An error occurred while instantiating action 'Export_InquirySummaryLogs'
    at com.mendix.core.action.ActionFactory.createActionForClass(ActionFactory.scala:84)

Caused by: java.lang.reflect.InvocationTargetException: null
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mendix.core.action.ActionFactory.createActionForClass(ActionFactory.scala:79)
    at com.mendix.core.action.ActionFactory.createJavaAction(ActionFactory.scala:49)
    at com.mendix.core.action.ActionFactory.createUserAction(ActionFactory.scala:44)
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:495)
    at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:52)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
    at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
    at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260)
    at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248)
    at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:172)
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:496)
    at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:144)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:312)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:302)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:302)
    at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:161)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:163)
    at scala.util.Try$.apply(Try.scala:192)
    at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:157)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:502)
    at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:153)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
    at akka.actor.ActorCell.invoke(ActorCell.scala:495)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Caused by: java.lang.Error: Unresolved compilation problems: 
    ALIGN_LEFT cannot be resolved or is not a field
    ALIGN_CENTER cannot be resolved or is not a field
    BORDER_MEDIUM cannot be resolved or is not a field
    LIME cannot be resolved or is not a field
    SOLID_FOREGROUND cannot be resolved or is not a field
    WHITE cannot be resolved or is not a field
    LIME cannot be resolved or is not a field
    BORDER_MEDIUM cannot be resolved or is not a field
    The method setBorderBottom(BorderStyle, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    The method setBorderTop(BorderStyle, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    The method setBorderLeft(BorderStyle, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    The method setBorderRight(BorderStyle, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    The method setBottomBorderColor(int, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    The method setTopBorderColor(int, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    The method setLeftBorderColor(int, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    The method setRightBorderColor(int, CellRangeAddress, Sheet) in the type RegionUtil is not applicable for the arguments (short, CellRangeAddress, HSSFSheet, HSSFWorkbook)
    CELL_TYPE_NUMERIC cannot be resolved or is not a field
    CELL_TYPE_NUMERIC cannot be resolved or is not a field
    The field HSSFFont.BOLDWEIGHT_BOLD is not visible
    ALIGN_CENTER cannot be resolved or is not a field
    The method setAlignment(HorizontalAlignment) in the type HSSFCellStyle is not applicable for the arguments (short)
    ALIGN_LEFT cannot be resolved or is not a field
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)
    The method setAlignment(Cell, HorizontalAlignment) in the type CellUtil is not applicable for the arguments (HSSFCell, HSSFWorkbook, short)

    at texisle.actions.Export_InquirySummaryLogs.<init>(Export_InquirySummaryLogs.java:83)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mendix.core.action.ActionFactory.createActionForClass(ActionFactory.scala:79)
    at com.mendix.core.action.ActionFactory.createJavaAction(ActionFactory.scala:49)
    at com.mendix.core.action.ActionFactory.createUserAction(ActionFactory.scala:44)
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:495)
    at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:52)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
    at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
    at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
    at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260)
    at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248)
    at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:172)
    at com.mendix.core.component.InternalCore.execute(InternalCore.java:496)
    at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:144)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:312)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:302)
    at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:302)
    at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:161)
    at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36)
    at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:163)
    at scala.util.Try$.apply(Try.scala:192)
    at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:157)
    at akka.actor.Actor$class.aroundReceive(Actor.scala:502)
    at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:153)
    at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
    at akka.actor.ActorCell.invoke(ActorCell.scala:495)
    at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
    at akka.dispatch.Mailbox.run(Mailbox.scala:224)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
 

How can I resolve this?

Thanks.

asked
3 answers
0

If it really worked in 6.10.4 then my best bet would be that there is an issue with the JAR files in your userlib folder. The Excel Exporter uses the Java Apache POI library. Other modules also use this library, like for instance the Excel Importer. Perhaps you updated that module, overwriting the correct JAR file the Excel Export module needs. So, please check the JAR files for the Apache POI library which were in the 6.10.4 code versus the ones in the 6.10.8 code. 

 

answered
0

I am using below java code to Export some logs from my application. The code is working fine in 6.10.4 version modeler. And I am getting issues with 6.10.18 version modeler.  The issues are due to HSSF library. Can anyone please let me know the root cause of the issues.

 


// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à, etc. are supported in comments.

package texisle.actions;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPalette;
import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellUtil;
import org.apache.poi.ss.util.RegionUtil;
import com.mendix.core.Core;
import com.mendix.core.CoreException;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import texisle.proxies.InquiryProduct;
import com.mendix.systemwideinterfaces.core.IMendixObject;

public class Export_InquirySummaryLogs extends CustomJavaAction<java.lang.Boolean>
{
    private java.util.List<IMendixObject> __InquiryProductsList;
    private java.util.List<texisle.proxies.InquiryProduct> InquiryProductsList;
    private IMendixObject __FileDocumentParameter1;
    private system.proxies.FileDocument FileDocumentParameter1;

    public Export_InquirySummaryLogs(IContext context, java.util.List<IMendixObject> InquiryProductsList, IMendixObject FileDocumentParameter1)
    {
        super(context);
        this.__InquiryProductsList = InquiryProductsList;
        this.__FileDocumentParameter1 = FileDocumentParameter1;
    }

    @Override
    public java.lang.Boolean executeAction() throws Exception
    {
        this.InquiryProductsList = new java.util.ArrayList<texisle.proxies.InquiryProduct>();
        if (__InquiryProductsList != null)
            for (IMendixObject __InquiryProductsListElement : __InquiryProductsList)
                this.InquiryProductsList.add(texisle.proxies.InquiryProduct.initialize(getContext(), __InquiryProductsListElement));

        this.FileDocumentParameter1 = __FileDocumentParameter1 == null ? null : system.proxies.FileDocument.initialize(getContext(), __FileDocumentParameter1);

        // BEGIN USER CODE
        return writeToExcel();
        // END USER CODE
    }

    /**
     * Returns a string representation of this action
     */
    @Override
    public java.lang.String toString()
    {
        return "Export_InquirySummaryLogs";
    }

    // BEGIN EXTRA CODE
    HSSFCellStyle style = null;
    HSSFFont font = null;
    short leftAlign = CellStyle.ALIGN_LEFT;
    short centerAlign = CellStyle.ALIGN_CENTER;
    short borderMediumDashed = CellStyle.BORDER_MEDIUM;
    
    /**
     *
     * @param value
     * @param columnNo
     * @param row
     * @return Create Cell with String value
     */
    @SuppressWarnings("deprecation")
    public HSSFCell createCell(HSSFWorkbook wb, String value, int columnNo, HSSFRow row) {
        HSSFCell cell = row.createCell((short) columnNo);
        if (value != null) {
            cell.setCellValue(value);
        }
        if(style == null) {
            style = wb.createCellStyle();
        }
        if(font == null) {
            font = wb.createFont();
        }
        font.setFontHeightInPoints((short) 11);
        font.setFontName("Calibri");
        style.setFont(font);
        cell.setCellStyle(style);

        return cell;
    }

    /**
     *
     * @param value
     * @param columnNo
     * @param row
     * @return Create Cell with Float value
     */
    @SuppressWarnings("deprecation")
    public HSSFCell createCellWithDouble(HSSFWorkbook wb, float value, int columnNo, HSSFRow row) {
        HSSFCell cell = row.createCell((short) columnNo);
        cell.setCellValue(value);

        if(style == null) {
            style = wb.createCellStyle();
        }
        if(font == null) {
            font = wb.createFont();
        }
        font.setFontHeightInPoints((short) 11);
        font.setFontName("Calibri");
        style.setFont(font);
        cell.setCellStyle(style);

        return cell;
    }

    @SuppressWarnings("deprecation")
    public HSSFCell createCellWithStyle(String value, int columnNo, HSSFRow row, HSSFWorkbook wb, boolean headerText) {
        HSSFCell cell = row.createCell((short) columnNo);
        cell.setCellValue(value);

        HSSFCellStyle style = wb.createCellStyle();
        style.setFillForegroundColor(HSSFColor.LIME.index);
        style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

        HSSFFont font = wb.createFont();
        font.setFontName("Calibri");
        font.setColor(HSSFColor.WHITE.index);
        if (headerText)
            font.setFontHeightInPoints((short) 12);
        else
            font.setFontHeightInPoints((short) 11);
        style.setFont(font);

        cell.setCellStyle(style);

        HSSFPalette palette = wb.getCustomPalette();
        palette.setColorAtIndex(HSSFColor.LIME.index, (byte) 164, (byte) 153, (byte) 0);
        return cell;
    }

    @SuppressWarnings("deprecation")
    public void createAllBorders(HSSFWorkbook wb, HSSFSheet sheet, int sr, int er, int sc, int ec) {
        org.apache.poi.hssf.util.CellRangeAddress region = new org.apache.poi.hssf.util.CellRangeAddress(sr, er, sc,
                ec);
        
        if(borderMediumDashed == 0) {
            borderMediumDashed = CellStyle.BORDER_MEDIUM;
        }
        RegionUtil.setBorderBottom(borderMediumDashed, region, sheet, wb);
        RegionUtil.setBorderTop(borderMediumDashed, region, sheet, wb);
        RegionUtil.setBorderLeft(borderMediumDashed, region, sheet, wb);
        RegionUtil.setBorderRight(borderMediumDashed, region, sheet, wb);
        RegionUtil.setBottomBorderColor(IndexedColors.BLACK.getIndex(), region, sheet, wb);
        RegionUtil.setTopBorderColor(IndexedColors.BLACK.getIndex(), region, sheet, wb);
        RegionUtil.setLeftBorderColor(IndexedColors.BLACK.getIndex(), region, sheet, wb);
        RegionUtil.setRightBorderColor(IndexedColors.BLACK.getIndex(), region, sheet, wb);
    }


    public void setDecimalNumberStyle(HSSFWorkbook wb, HSSFCell cell) {
        if(style == null) {
            style = wb.createCellStyle();
        }
        style.setDataFormat(wb.createDataFormat().getFormat("#,##,###.00"));
        cell.setCellStyle(style);
        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

        if(font == null) {
            font = wb.createFont();
        }
        font.setFontName("Calibri");
        font.setFontHeightInPoints((short) 11);
        style.setFont(font);
    }
    
    public void setDecimalNumberStyleWith3Decimals(HSSFWorkbook wb, HSSFCell cell) {
        if(style == null) {
            style = wb.createCellStyle();
        }
        style.setDataFormat(wb.createDataFormat().getFormat("#,##,###.000"));
        cell.setCellStyle(style);
        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);

        if(font == null) {
            font = wb.createFont();
        }
        font.setFontName("Calibri");
        font.setFontHeightInPoints((short) 11);
        style.setFont(font);
    }
    
    HSSFCellStyle style1 = null;
    HSSFFont font1 = null;
    public void createHeader(HSSFWorkbook wb, HSSFSheet sheet,HSSFRow row, int rowNo, String headerName, int sc, int ec) {
        Cell list = createCell(wb, headerName, sc, row);
        if(style1 == null) {
            style1 = wb.createCellStyle();
        }
        
        if(font1 == null) {
            font1 = wb.createFont();
        }
        
        font1.setFontHeightInPoints((short) 11);
        font1.setFontName("Calibri");
        font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
        style1.setFont(font1);
        if(centerAlign == 0) {
            centerAlign = CellStyle.ALIGN_CENTER;
        }
        style1.setAlignment(centerAlign);
        list.setCellStyle(style1);
        sheet.addMergedRegion(new org.apache.poi.hssf.util.CellRangeAddress(rowNo, rowNo, sc, ec));
    }
    
    @SuppressWarnings("deprecation")
    public Boolean writeToExcel() {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet();
        HSSFPrintSetup printSetup = sheet.getPrintSetup();
        printSetup.setLandscape(true);
        printSetup.setPaperSize(HSSFPrintSetup.LETTER_PAPERSIZE);
        sheet.setAutobreaks(true);
        sheet.setFitToPage(true);
        printSetup.setFitWidth((short) 1);
        printSetup.setFitHeight((short) 1);
        printSetup.setFooterMargin(0.3D);
        printSetup.setHeaderMargin(0.3D);
        sheet.setMargin(Sheet.LeftMargin, 0.7D);
        sheet.setMargin(Sheet.RightMargin, 0.7D);
        sheet.setMargin(Sheet.TopMargin, 0.75D);
        sheet.setMargin(Sheet.BottomMargin, 0.75D);
        
        if(leftAlign == 0) {
            leftAlign = CellStyle.ALIGN_LEFT;
        }

        int rowNo = 0;
        //Merging rows
        sheet.addMergedRegion(new org.apache.poi.hssf.util.CellRangeAddress(rowNo, rowNo, 0, 25));
        //Cost Types Row
        HSSFRow row0 = sheet.createRow((short) rowNo);
        
        //Tube Mill Header
        createHeader(wb, sheet, row0, rowNo, "Tube Mill", 26, 29);
        
        //Tube Distributor Header
        createHeader(wb, sheet, row0, rowNo, "Tube Distributor", 30, 33);
        
        //Freight Header
        createHeader(wb, sheet, row0, rowNo, "Freight", 34, 37);
        
        //Port Charges Header
        createHeader(wb, sheet, row0, rowNo, "Port Charges", 38, 40);
        
        //Yard Charges/Inspection/Crop Loss/Other Header
        createHeader(wb, sheet, row0, rowNo, "Yard Charges/Inspection/Crop Loss/Other", 41, 43);
        
        //OD Coating Header
        createHeader(wb, sheet, row0, rowNo, "OD Coating", 44, 47);
        
        //ID Coating Header
        createHeader(wb, sheet, row0, rowNo, "ID Coating", 48, 51);
        
        //Heat Treat Header
        createHeader(wb, sheet, row0, rowNo, "Heat Treat", 52, 55);
        
        //Threading Header
        createHeader(wb, sheet, row0, rowNo, "Threading", 56, 59);
        
        //Coupling Header
        createHeader(wb, sheet, row0, rowNo, "Coupling", 60, 63);
        
        //Mechanical Connection Header
        createHeader(wb, sheet, row0, rowNo, "Mechanical Connection", 64, 66);
        
        //Thread Protector Header
        createHeader(wb, sheet, row0, rowNo, "Thread Protector", 67, 70);
        
        //Totals Header
        createHeader(wb, sheet, row0, rowNo, "Totals", 71, 77);
        
        rowNo++;
        
        // Inquiry Quote Items Header Panel
        HSSFRow row1 = sheet.createRow((short) rowNo);
        CellUtil.setAlignment(createCellWithStyle("Quote #", 0, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Date Initiated", 1, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Due Date", 2, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Date Submitted", 3, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Pipe Required by Date", 4, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Status", 5, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Inside Rep", 6, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Outside Rep", 7, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Customer", 8, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Inquiry Name", 9, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Inquiry Type", 10, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Product Type", 11, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Service Type", 12, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Delivery Type", 13, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Delivery Location", 14, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Basin", 15, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("OD", 16, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Wall/PFF/SDR", 17, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Grade", 18, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Inspection", 19, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Thread", 20, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Process", 21, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("OD Coating", 22, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("ID Coating", 23, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Quantity", 24, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Total Tons", 25, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 26, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Mill Info", 27, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Tube Cost ($/FT)", 28, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Tube Cost ($/T)", 29, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 30, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Mill Info", 31, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Tube Cost ($/FT)", 32, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Tube Cost ($/T)", 33, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("# of Trucks", 34, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Avg. Cost Per Truck", 35, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Avg. Cost $/FT", 36, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Avg. Cost $/Ton", 37, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 38, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 39, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 40, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 41, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 42, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 43, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 44, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 45, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 46, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Coating Type", 47, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 48, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 49, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 50, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Coating Type", 51, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 52, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Grade Processed", 53, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 54, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 55, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 56, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Connection", 57, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 58, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 59, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 60, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Coupling Type", 61, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 62, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 63, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 64, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 65, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 66, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Vendor", 67, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Thread Protect Type", 68, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost ($/ft)", 69, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Cost $/Ton", 70, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Total Cost of Good - $/Ton", 71, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Total Cost of Good - $/FT", 72, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Profit $/FT", 73, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Profit $/Ton", 74, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Quoted Cost of Good - $/Ton", 75, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Quoted Cost of Good - $/FT", 76, row1, wb, false), wb, leftAlign);
        CellUtil.setAlignment(createCellWithStyle("Price of Pipe Per Ton Yard", 77, row1, wb, false), wb, leftAlign);
        
        rowNo++;
        
        //Product Type variable
        String productType = null;
        
        //Service Type variable
        String serviceType = null;
        
        if (InquiryProductsList.size() > 0) {
            
            // Inquiry Quotes Items
            for (InquiryProduct inquiryProduct : InquiryProductsList) {
                
                //Setting Product Type, Service Type values
                if(inquiryProduct.getType_().getCaption() != null) {
                    if(inquiryProduct.getType_().getCaption() == "Product" || inquiryProduct.getType_().getCaption() == "Accessory") {
                        productType = inquiryProduct.getInquiryProductType().getCaption();
                        serviceType = null;
                    } else if(inquiryProduct.getType_().getCaption() == "Service") {
                        serviceType = inquiryProduct.getInquiryServiceType().getCaption();
                        productType = null;
                    } else {
                        productType = null;
                        serviceType = null;
                    }
                }
                else {
                    productType = null;
                    serviceType = null;
                }
                
                HSSFRow row2 = sheet.createRow((short) rowNo);
                //Quote Number Value
                Long quoteNo = null;
                HSSFCell quoteNoCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getQuoteNumber() != null) {
                        quoteNo = inquiryProduct.getInquiry_InquiryProduct().getQuoteNumber();
                    }
                    else {
                        quoteNo = null;
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for Quote Number in Database.");
                    e.printStackTrace();
                }
                quoteNoCell = createCell(wb, quoteNo == null ? "NA"
                        : quoteNo.toString(), 0, row2);
                CellUtil.setAlignment(quoteNoCell, wb, leftAlign);
                
                //Date Initiated Value
                Date date = inquiryProduct.getMendixObject().getValue(getContext(), "createdDate");
                DateFormat df = new SimpleDateFormat("MM-dd-yyyy");
                df.setTimeZone(TimeZone.getTimeZone("UTC"));
                String myFormattedDate = df.format(date);
                HSSFCell initDateCell = createCell(wb, myFormattedDate == null ? "NA"
                        : myFormattedDate.toString(), 1, row2);
                CellUtil.setAlignment(initDateCell, wb, leftAlign);
                
                //Due Date Value
                Date dueDate;
                String myFormattedDueDate = null;
                try {
                    dueDate = inquiryProduct.getInquiry_InquiryProduct().getQuoteDueBy();
                    if(dueDate != null) {
                        myFormattedDueDate = df.format(dueDate);
                    }
                    else {
                        myFormattedDueDate = null;
                    }
                } catch (CoreException e1) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for QuoteDueBy Date in Database.");
                    e1.printStackTrace();
                }
                HSSFCell dueDateCell = createCell(wb, myFormattedDueDate == null ? "NA"
                        : myFormattedDueDate, 2, row2);
                CellUtil.setAlignment(dueDateCell, wb, leftAlign);
                
                //Date Submitted Value
                Date submittedDate;
                String submittedDateFormat = null;
                try {
                    submittedDate = inquiryProduct.getLastQuoteCreatedDate();
                    if(submittedDate != null) {
                        submittedDateFormat = df.format(submittedDate);
                    }
                    else {
                        submittedDateFormat = null;
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for Quote CreatedDate in Database.");
                    e.printStackTrace();
                }
                HSSFCell submitDateCell = createCell(wb, submittedDateFormat == null ? "NA"
                        : submittedDateFormat, 3, row2);
                CellUtil.setAlignment(submitDateCell, wb, leftAlign);
                
                //Pipe Required By Date Value
                Date pipeReqDate;
                String myFormattedPipeReqDate = null;
                try {
                    pipeReqDate = inquiryProduct.getPipeRequiredBy();
                    if(pipeReqDate != null) {
                        myFormattedPipeReqDate = df.format(pipeReqDate);
                    }
                    else {
                        myFormattedPipeReqDate = null;
                    }
                    
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for PipeRequiredBy Date in Database.");
                    e.printStackTrace();
                }
                HSSFCell pipeReqDateCell = createCell(wb, myFormattedPipeReqDate == null ? "NA"
                        : myFormattedPipeReqDate, 4, row2);
                CellUtil.setAlignment(pipeReqDateCell, wb, leftAlign);
                
                //Status Value
                String status = null;
                HSSFCell statusCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getStatus_New().getCaption() != null) {
                        status = inquiryProduct.getInquiry_InquiryProduct().getStatus_New().getCaption();
                    }
                    else {
                        status = null;
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for Status in Database.");
                    e.printStackTrace();
                }
                statusCell = createCell(wb, status == null ? "NA"
                        : status, 5, row2);
                CellUtil.setAlignment(statusCell, wb, leftAlign);
                
                //Inside Rep Value
                String insideRep = null;
                HSSFCell insideRepCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getInsideSalesLead().getFullName() != null) {
                        insideRep = inquiryProduct.getInquiry_InquiryProduct().getInsideSalesLead().getFullName();
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for InsideSalesRep in Database.");
                    e.printStackTrace();
                }
                insideRepCell = createCell(wb, insideRep == null ? "NA"
                        : insideRep, 6, row2);
                CellUtil.setAlignment(insideRepCell, wb, leftAlign);
                
                //Outside Rep Value
                String outsideRep = null;
                HSSFCell outsideRepCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getOutsideSalesLead().getFullName() != null) {
                        outsideRep = inquiryProduct.getInquiry_InquiryProduct().getOutsideSalesLead().getFullName();
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for OutsideSalesRep in Database.");
                    e.printStackTrace();
                }
                outsideRepCell = createCell(wb, outsideRep == null ? "NA"
                        : outsideRep, 7, row2);
                CellUtil.setAlignment(outsideRepCell, wb, leftAlign);
                
                //Customer Value
                String customer = null;
                HSSFCell customerCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getInquiry_Customer().getName() != null) {
                        customer = inquiryProduct.getInquiry_InquiryProduct().getInquiry_Customer().getName();
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for Inquiry Customer in Database.");
                    e.printStackTrace();
                }
                customerCell = createCell(wb, customer == null ? "NA"
                        : customer, 8, row2);
                CellUtil.setAlignment(customerCell, wb, leftAlign);
                
                //Inquiry Name Value
                String inquiry = null;
                HSSFCell inquiryNameCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getName() != null) {
                        inquiry = inquiryProduct.getInquiry_InquiryProduct().getName();
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for Inquiry Name in Database.");
                    e.printStackTrace();
                }
                inquiryNameCell = createCell(wb, (inquiry == null || inquiry.isEmpty()) ? "NA"
                        : inquiry, 9, row2);
                CellUtil.setAlignment(inquiryNameCell, wb, leftAlign);
                
                //Inquiry Type Value
                String inquiryType = null;
                HSSFCell inquiryTypeCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getInquiryType().getCaption() != null) {
                        inquiryType = inquiryProduct.getInquiry_InquiryProduct().getInquiryType().getCaption();
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for InquiryType in Database.");
                    e.printStackTrace();
                }
                inquiryTypeCell = createCell(wb, inquiryType == null ? "NA"
                        : inquiryType, 10, row2);
                CellUtil.setAlignment(inquiryTypeCell, wb, leftAlign);
                
                //Product Type Value
                HSSFCell productTypeCell = createCell(wb, productType == null ? "NA"
                        : productType, 11, row2);
                CellUtil.setAlignment(productTypeCell, wb, leftAlign);
                
                //Service Type Value
                HSSFCell serviceTypeCell = createCell(wb, serviceType == null ? "NA"
                        : serviceType, 12, row2);
                CellUtil.setAlignment(serviceTypeCell, wb, leftAlign);
                
                //Delivery Type Value
                String deliveryType = null;
                HSSFCell deliveryTypeCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getDeliveryFOBPoint().getCaption() != null) {
                        deliveryType = inquiryProduct.getInquiry_InquiryProduct().getDeliveryFOBPoint().getCaption();
                    }
                    else {
                        deliveryType = null;
                    }
                } catch (Exception e1) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for DeliveryFOBPoint in Database.");
                    e1.printStackTrace();
                }
                deliveryTypeCell = createCell(wb,  deliveryType == null ? "NA"
                        : deliveryType, 13, row2);
                CellUtil.setAlignment(deliveryTypeCell, wb, leftAlign);
                
                //Delivery Location Value
                String deliLocation = null;
                if(inquiryProduct.getDeliveryCity() != null) {
                    deliLocation = inquiryProduct.getDeliveryCity();
                }
                else {
                    deliLocation = null;
                }
                HSSFCell deliveryLocationCell = createCell(wb,  deliLocation == null ? "NA"
                        : deliLocation, 14, row2);
                CellUtil.setAlignment(deliveryLocationCell, wb, leftAlign);
                
                //Basin Value
                String basin = null;
                HSSFCell basinCell = null;
                try {
                    if(inquiryProduct.getInquiry_InquiryProduct().getOperatingRegion_() != null) {
                        basin = inquiryProduct.getInquiry_InquiryProduct().getOperatingRegion_();
                    }
                    else {
                        basin = null;
                    }
                } catch (Exception e) {
                    Core.getLogger("Tex-Isle Java Action - InquirySummaryLog").warn("No values for Operating Region in Database.");
                    e.printStackTrace();
                }
                basinCell = createCell(wb, (basin == null || basin.isEmpty()) ? "NA"
                        : basin, 15, row2);
                CellUtil.setAlignment(basinCell, wb, leftAlign);
                
                //OD Value
                BigDecimal odDisAs = null;
                if(inquiryProduct.getOD_DisplayAs() != null) {
                    odDisAs = inquiryProduct.getOD_DisplayAs();
                }
                else {
                    odDisAs = null;
                }
                HSSFCell odCell = createCellWithDouble(wb,  odDisAs == null ? 0
                        : Float.parseFloat(odDisAs.toString()), 16, row2);
                setDecimalNumberStyleWith3Decimals(wb, odCell);
                CellUtil.setAlignment(odCell, wb, leftAlign);
                
                //Wall/PPF/SDR Value
                BigDecimal wallPPFSDR = null;
                if(inquiryProduct.getWallPPFSDR_DisplayAs() != null) {
                    wallPPFSDR = inquiryProduct.getWallPPFSDR_DisplayAs();
                }
                else {
                    wallPPFSDR = null;
                }
                HSSFCell wallCell = createCellWithDouble(wb, wallPPFSDR == null ?0
                        : Float.parseFloat(wallPPFSDR.toString()), 17, row2);
                setDecimalNumberStyleWith3Decimals(wb, wallCell);
                CellUtil.setAlignment(wallCell, wb, leftAlign);
                
                //Grade Value
                String grade = null;
                if(inquiryProduct.getGrade_Text() == null || inquiryProduct.getGrade_Text().isEmpty()) {
                    grade = null;
                }
                else {
                    grade = inquiryProduct.getGrade_Text();
                }
                HSSFCell gradeCell = createCell(wb, grade == null ? "NA"
                        : grade, 18, row2);
                CellUtil.setAlignment(gradeCell, wb, leftAlign);
                
                //Inspection Value
                String inspection = null;
                if(inquiryProduct.getPSL_Text() == null || inquiryProduct.getPSL_Text().isEmpty()) {
                    inspection = null;
                }
                else {
                    inspection = inquiryProduct.getPSL_Text();
                }
                HSSFCell inspectionCell = createCell(wb, inspection == null ? "NA"
                        : inspection, 19, row2);
                CellUtil.setAlignment(inspectionCell, wb, leftAlign);
                
                //Thread Value
                String thread = null;
                if(inquiryProduct.getThreadEndStick_Text() == null || inquiryProduct.getThreadEndStick_Text().isEmpty()) {
                    thread = null;
                }
                else {
                    thread = inquiryProduct.getThreadEndStick_Text();
                }
                HSSFCell threadCell = createCell(wb, thread == null ? "NA"
                        : thread, 20, row2);
                CellUtil.setAlignment(threadCell, wb, leftAlign);
                
                //Process Value
                String process = null;
                if(inquiryProduct.getProcess_Text() == null || inquiryProduct.getProcess_Text().isEmpty()) {
                    process = null;
                }
                else {
                    process = inquiryProduct.getProcess_Text();
                }
                HSSFCell processCell = createCell(wb, process == null ? "NA"
                        : process, 21, row2);
                CellUtil.setAlignment(processCell, wb, leftAlign);
                
                //OD Coating Value
                String odCoating = null;
                if(inquiryProduct.getODCoating_Text() == null || inquiryProduct.getODCoating_Text().isEmpty()) {
                    odCoating = null;
                }
                else {
                    odCoating = inquiryProduct.getODCoating_Text();
                }
                HSSFCell odCoatingCell = createCell(wb, odCoating == null ? "NA"
                        : odCoating, 22, row2);
                CellUtil.setAlignment(odCoatingCell, wb, leftAlign);
                
                //ID Coating Value
                String idCoating = null;
                if(inquiryProduct.getIDCoating_Text() == null || inquiryProduct.getIDCoating_Text().isEmpty()) {
                    idCoating = null;
                }
                else{
                    idCoating = inquiryProduct.getIDCoating_Text();
                }
                HSSFCell idCoatingCell = createCell(wb, idCoating == null ? "NA"
                        : idCoating, 23, row2);
                CellUtil.setAlignment(idCoatingCell, wb, leftAlign);
                
                //Quantity Value
                BigDecimal quantity = null;
                if(inquiryProduct.getQuantity() != null) {
                    quantity = inquiryProduct.getQuantity();
                }
                else {
                    quantity = null;
                }
                HSSFCell quantityCell = createCellWithDouble(wb, quantity == null ? 0
                        : Float.parseFloat(quantity.toString()), 24, row2);
                setDecimalNumberStyle(wb, quantityCell);
                CellUtil.setAlignment(quantityCell, wb, leftAlign);
                
                //Total Tons Value
                BigDecimal totalTons = null;
                if(inquiryProduct.getQuantityTons() != null) {
                    totalTons = inquiryProduct.getQuantityTons();
                }
                else {
                    totalTons = null;
                }
                HSSFCell totalTonsCell = createCellWithDouble(wb, totalTons == null ? 0
                        : Float.parseFloat(totalTons.toString()), 25, row2);
                setDecimalNumberStyleWith3Decimals(wb, totalTonsCell);
                CellUtil.setAlignment(totalTonsCell, wb, leftAlign);
                
                //Tube Mill Values
                //Vendor
                String tmVendor = null;
                if(inquiryProduct.getTubeMill_Vendor() != null) {
                    tmVendor = inquiryProduct.getTubeMill_Vendor();
                }
                else {
                    tmVendor = null;
                }
                HSSFCell tubeMillVendor = createCell(wb, tmVendor == null ? "NA"
                        : tmVendor, 26, row2);
                CellUtil.setAlignment(tubeMillVendor, wb, leftAlign);
                //Mill Info
                String tmMillInfo = null;
                if(inquiryProduct.getTubeMill_Mill_Info() != null) {
                    tmMillInfo = inquiryProduct.getTubeMill_Mill_Info();
                }
                else {
                    tmMillInfo = null;
                }
                HSSFCell tubeMillInfo = createCell(wb, tmMillInfo == null ? "NA"
                        : tmMillInfo, 27, row2);
                CellUtil.setAlignment(tubeMillInfo, wb, leftAlign);
                //Tube Cost FT
                BigDecimal tmCostFt = null;
                if(inquiryProduct.getTubeMill_Price_Ft() != null) {
                    tmCostFt = inquiryProduct.getTubeMill_Price_Ft();
                }
                else {
                    tmCostFt = null;
                }
                HSSFCell tubeMill_CostFt = createCellWithDouble(wb, tmCostFt == null ? 0
                        : Float.parseFloat(tmCostFt.toString()), 28, row2);
                setDecimalNumberStyle(wb, tubeMill_CostFt);
                CellUtil.setAlignment(tubeMill_CostFt, wb, leftAlign);
                //Tube Cost Ton
                BigDecimal tmCostTon = null;
                if(inquiryProduct.getTubeMill_Price_Tons() != null) {
                    tmCostTon = inquiryProduct.getTubeMill_Price_Tons();
                }
                else {
                    tmCostTon = null;
                }
                HSSFCell tubeMill_CostTon = createCellWithDouble(wb, tmCostTon == null ? 0
                        : Float.parseFloat(tmCostTon.toString()), 29, row2);
                setDecimalNumberStyle(wb, tubeMill_CostTon);
                CellUtil.setAlignment(tubeMill_CostTon, wb, leftAlign);
                
                //Tube Distributor Values
                //Vendor
                String tdVendor = null;
                if(inquiryProduct.getTubeDistributor_Vendor() != null) {
                    tdVendor = inquiryProduct.getTubeDistributor_Vendor();
                }
                else {
                    tdVendor = null;
                }
                HSSFCell tubeDistributorVendor = createCell(wb, tdVendor == null ? "NA"
                        : tdVendor, 30, row2);
                CellUtil.setAlignment(tubeDistributorVendor, wb, leftAlign);
                //Mill Info
                String tdMillInfo = null;
                if(inquiryProduct.getTubeDistributor_Mill_Info() != null) {
                    tdMillInfo = inquiryProduct.getTubeDistributor_Mill_Info();
                }
                else {
                    tdMillInfo = null;
                }
                HSSFCell tubeDistributorInfo = createCell(wb, tdMillInfo == null ? "NA"
                        : tdMillInfo, 31, row2);
                CellUtil.setAlignment(tubeDistributorInfo, wb, leftAlign);
                //Tube Cost FT
                BigDecimal tdCostFt = null;
                if(inquiryProduct.getTubeDistributor_Price_Ft() != null) {
                    tdCostFt = inquiryProduct.getTubeDistributor_Price_Ft();
                }
                else {
                    tdCostFt = null;
                }
                HSSFCell tubeDistributor_CostFt = createCellWithDouble(wb, tdCostFt == null ? 0
                        : Float.parseFloat(tdCostFt.toString()), 32, row2);
                setDecimalNumberStyle(wb, tubeDistributor_CostFt);
                CellUtil.setAlignment(tubeDistributor_CostFt, wb, leftAlign);
                //Tube Cost Ton
                BigDecimal tdCostTon = null;
                if(inquiryProduct.getTubeDistributor_Price_Tons() != null) {
                    tdCostTon = inquiryProduct.getTubeDistributor_Price_Tons();
                }
                else {
                    tdCostTon = null;
                }
                HSSFCell tubeDistributor_CostTon = createCellWithDouble(wb, tdCostTon == null ? 0
                        : Float.parseFloat(tdCostTon.toString()), 33, row2);
                setDecimalNumberStyle(wb, tubeDistributor_CostTon);
                CellUtil.setAlignment(tubeDistributor_CostTon, wb, leftAlign);
                
                //Freight Values
                //# of Trucks
                BigDecimal trucksNo = null;
                if(inquiryProduct.getFreight_No_of_Trucks() != null) {
                    trucksNo = inquiryProduct.getFreight_No_of_Trucks();
                }
                else {
                    trucksNo = null;
                }
                HSSFCell no_Trucks = createCellWithDouble(wb, trucksNo == null ? 0
                        : Float.parseFloat(trucksNo.toString()), 34, row2);
                setDecimalNumberStyle(wb, no_Trucks);
                CellUtil.setAlignment(no_Trucks, wb, leftAlign);
                //Avg.Cost Per Truck
                BigDecimal avgCostTruck = null;
                if(inquiryProduct.getFreight_Avg_CostPerTruck() != null) {
                    avgCostTruck = inquiryProduct.getFreight_Avg_CostPerTruck();
                }
                else {
                    avgCostTruck = null;
                }
                HSSFCell costPerTruck = createCellWithDouble(wb, avgCostTruck == null ? 0
                        : Float.parseFloat(avgCostTruck.toString()), 35, row2);
                setDecimalNumberStyle(wb, costPerTruck);
                CellUtil.setAlignment(costPerTruck, wb, leftAlign);
                //Avg.Cost Per Feet
                BigDecimal avgCostFt = null;
                if(inquiryProduct.getFreight_Avg_Cost_Ft() != null) {
                    avgCostFt = inquiryProduct.getFreight_Avg_Cost_Ft();
                }
                else {
                    avgCostFt = null;
                }
                HSSFCell costPerFeet = createCellWithDouble(wb, avgCostFt == null ? 0
                        : Float.parseFloat(avgCostFt.toString()), 36, row2);
                setDecimalNumberStyle(wb, costPerFeet);
                CellUtil.setAlignment(costPerFeet, wb, leftAlign);
                //Avg.Cost Per Ton
                BigDecimal avgCostTon = null;
                if(inquiryProduct.getFreight_Avg_Cost_Ton() != null) {
                    avgCostTon = inquiryProduct.getFreight_Avg_Cost_Ton();
                }
                else {
                    avgCostTon = null;
                }
                HSSFCell costPerTon = createCellWithDouble(wb, avgCostTon == null ? 0
                        : Float.parseFloat(avgCostTon.toString()), 37, row2);
                setDecimalNumberStyle(wb, costPerTon);
                CellUtil.setAlignment(costPerTon, wb, leftAlign);
                
                //Port Charges Values
                //Cost Per Feet
                BigDecimal portCostFt = null;
                if(inquiryProduct.getPortCharges_Price_Ft() != null) {
                    portCostFt = inquiryProduct.getPortCharges_Price_Ft();
                }
                else {
                    portCostFt = null;
                }
                HSSFCell portCostPerFeet = createCellWithDouble(wb, portCostFt == null ? 0
                        : Float.parseFloat(portCostFt.toString()), 38, row2);
                setDecimalNumberStyle(wb, portCostPerFeet);
                CellUtil.setAlignment(portCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal portCostTon = null;
                if(inquiryProduct.getPortCharges_Price_Ton() != null) {
                    portCostTon = inquiryProduct.getPortCharges_Price_Ton();
                }
                else {
                    portCostTon = null;
                }
                HSSFCell portCostPerTon = createCellWithDouble(wb, portCostTon == null ? 0
                        : Float.parseFloat(portCostTon.toString()), 39, row2);
                setDecimalNumberStyle(wb, portCostPerTon);
                CellUtil.setAlignment(portCostPerTon, wb, leftAlign);
                //Vendor
                String pVendor = null;
                if(inquiryProduct.getPortCharges_Vendor() != null) {
                    pVendor = inquiryProduct.getPortCharges_Vendor();
                }
                else {
                    pVendor = null;
                }
                HSSFCell portVendor = createCell(wb, pVendor == null ? "NA"
                        : pVendor, 40, row2);
                CellUtil.setAlignment(portVendor, wb, leftAlign);
                
                //Yard Charges/Inspection/Crop Loss/Other Values
                //Cost Per Feet
                BigDecimal ycioCostFt = null;
                if(inquiryProduct.getYard_Inspection_Crop_Other_Cost_Ft() != null) {
                    ycioCostFt = inquiryProduct.getYard_Inspection_Crop_Other_Cost_Ft();
                }
                else {
                    ycioCostFt = null;
                }
                HSSFCell YICOCostPerFeet = createCellWithDouble(wb, ycioCostFt == null ? 0
                        : Float.parseFloat(ycioCostFt.toString()), 41, row2);
                setDecimalNumberStyle(wb, YICOCostPerFeet);
                CellUtil.setAlignment(YICOCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal ycioCostTon = null;
                if(inquiryProduct.getYard_Inspection_Crop_Other_Cost_Ton() != null) {
                    ycioCostTon = inquiryProduct.getYard_Inspection_Crop_Other_Cost_Ton();
                }
                else {
                    ycioCostTon = null;
                }
                HSSFCell YICOCostPerTon = createCellWithDouble(wb, ycioCostTon == null ? 0
                        : Float.parseFloat(ycioCostTon.toString()), 42, row2);
                setDecimalNumberStyle(wb, YICOCostPerTon);
                CellUtil.setAlignment(YICOCostPerTon, wb, leftAlign);
                //Vendor
                String yVendor = null;
                if(inquiryProduct.getYard_Inspection_Crop_Other_Vendor() != null) {
                    yVendor = inquiryProduct.getYard_Inspection_Crop_Other_Vendor();
                }
                else {
                    yVendor = null;
                }
                HSSFCell YICOVendor = createCell(wb, yVendor == null ? "NA"
                        : yVendor, 43, row2);
                CellUtil.setAlignment(YICOVendor, wb, leftAlign);
                
                //OD Coating Values
                //Cost Per Feet
                BigDecimal odCostFt = null;
                if(inquiryProduct.getODCoating_Price_Ft() != null) {
                    odCostFt = inquiryProduct.getODCoating_Price_Ft();
                }
                else {
                    odCostFt = null;
                }
                HSSFCell odCostPerFeet = createCellWithDouble(wb, odCostFt == null ? 0
                        : Float.parseFloat(odCostFt.toString()), 44, row2);
                setDecimalNumberStyle(wb, odCostPerFeet);
                CellUtil.setAlignment(odCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal odCostTon = null;
                if(inquiryProduct.getODCoating_Price_Ton() != null) {
                    odCostTon = inquiryProduct.getODCoating_Price_Ton();
                }
                else {
                    odCostTon = null;
                }
                HSSFCell odCostPerTon = createCellWithDouble(wb, odCostTon == null ? 0
                        : Float.parseFloat(odCostTon.toString()), 45, row2);
                setDecimalNumberStyle(wb, odCostPerTon);
                CellUtil.setAlignment(odCostPerTon, wb, leftAlign);
                //Vendor
                String oVendor = null;
                if(inquiryProduct.getODCoating_Vendor() != null) {
                    oVendor = inquiryProduct.getODCoating_Vendor();
                }
                else {
                    oVendor = null;
                }
                HSSFCell odVendor = createCell(wb, oVendor == null ? "NA"
                        : oVendor, 46, row2);
                CellUtil.setAlignment(odVendor, wb, leftAlign);
                //Coating Type
                String oCoatingType = null;
                if(inquiryProduct.getODCoating_CoatingType() != null) {
                    oCoatingType = inquiryProduct.getODCoating_CoatingType();
                }
                else {
                    oCoatingType = null;
                }
                HSSFCell odCoatingType = createCell(wb, oCoatingType == null ? "NA"
                        : oCoatingType, 47, row2);
                CellUtil.setAlignment(odCoatingType, wb, leftAlign);
                
                //ID Coating Values
                //Cost Per Feet
                BigDecimal idCostFT = null;
                if(inquiryProduct.getIDCoating_Price_Ft() != null) {
                    idCostFT = inquiryProduct.getIDCoating_Price_Ft();
                }
                else {
                    idCostFT = null;
                }
                HSSFCell idCostPerFeet = createCellWithDouble(wb, idCostFT == null ? 0
                        : Float.parseFloat(idCostFT.toString()), 48, row2);
                setDecimalNumberStyle(wb, idCostPerFeet);
                CellUtil.setAlignment(idCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal idCostTon = null;
                if(inquiryProduct.getIDCoating_Price_Ton() != null) {
                    idCostTon = inquiryProduct.getIDCoating_Price_Ton();
                }
                else {
                    idCostTon = null;
                }
                HSSFCell idCostPerTon = createCellWithDouble(wb, idCostTon == null ? 0
                        : Float.parseFloat(idCostTon.toString()), 49, row2);
                setDecimalNumberStyle(wb, idCostPerTon);
                CellUtil.setAlignment(idCostPerTon, wb, leftAlign);
                //Vendor
                String iVendor = null;
                if(inquiryProduct.getIDCoating_Vendor() != null) {
                    iVendor = inquiryProduct.getIDCoating_Vendor();
                }
                else {
                    iVendor = null;
                }
                HSSFCell idVendor = createCell(wb, iVendor == null ? "NA"
                        : iVendor, 50, row2);
                CellUtil.setAlignment(idVendor, wb, leftAlign);
                //Coating Type
                String iCoatingType = null;
                if(inquiryProduct.getIDCoating_CoatingType() != null) {
                    iCoatingType = inquiryProduct.getIDCoating_CoatingType();
                }
                else {
                    iCoatingType = null;
                }
                HSSFCell idCoatingType = createCell(wb, iCoatingType == null ? "NA"
                        : iCoatingType, 51, row2);
                CellUtil.setAlignment(idCoatingType, wb, leftAlign);
                
                //Heat Treat Values
                //Vendor
                String hVendor = null;
                if(inquiryProduct.getHeatTreat_Vendor() != null) {
                    hVendor = inquiryProduct.getHeatTreat_Vendor();
                }
                else {
                    hVendor = null;
                }
                HSSFCell heatVendor = createCell(wb, hVendor == null ? "NA"
                        : hVendor, 52, row2);
                CellUtil.setAlignment(heatVendor, wb, leftAlign);
                //Grade Processed
                String hGrade = null;
                if(inquiryProduct.getHeatTreat_GradeProcessed() != null) {
                    hGrade = inquiryProduct.getHeatTreat_GradeProcessed();
                }
                else {
                    hGrade = null;
                }
                HSSFCell heatGrade = createCell(wb, hVendor == null ? "NA"
                        : hGrade, 53, row2);
                CellUtil.setAlignment(heatGrade, wb, leftAlign);
                //Cost Per Feet
                BigDecimal hCostFT = null;
                if(inquiryProduct.getHeatTreat_Price_Ft() != null) {
                    hCostFT = inquiryProduct.getHeatTreat_Price_Ft();
                }
                else {
                    hCostFT = null;
                }
                HSSFCell heatCostPerFeet = createCellWithDouble(wb, hCostFT == null ? 0
                        : Float.parseFloat(hCostFT.toString()), 54, row2);
                setDecimalNumberStyle(wb, heatCostPerFeet);
                CellUtil.setAlignment(heatCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal hCostTon = null;
                if(inquiryProduct.getHeatTreat_Price_Ton() != null) {
                    hCostTon = inquiryProduct.getHeatTreat_Price_Ton();
                }
                else {
                    hCostTon = null;
                }
                HSSFCell heatCostPerTon = createCellWithDouble(wb, hCostTon == null ? 0
                        : Float.parseFloat(hCostTon.toString()), 55, row2);
                setDecimalNumberStyle(wb, heatCostPerTon);
                CellUtil.setAlignment(heatCostPerTon, wb, leftAlign);
                
                //Threading Values
                //Vendor
                String tVendor = null;
                if(inquiryProduct.getThreading_Vendor() != null) {
                    tVendor = inquiryProduct.getThreading_Vendor();
                }
                else {
                    tVendor = null;
                }
                HSSFCell threadingVendor = createCell(wb, tVendor == null ? "NA"
                        : tVendor, 56, row2);
                CellUtil.setAlignment(threadingVendor, wb, leftAlign);
                //Connection
                String tConnection = null;
                if(inquiryProduct.getThreading_Connection() != null) {
                    tConnection = inquiryProduct.getThreading_Connection();
                }
                else {
                    tConnection = null;
                }
                HSSFCell threadingConnection = createCell(wb, tConnection == null ? "NA"
                        : tConnection, 57, row2);
                CellUtil.setAlignment(threadingConnection, wb, leftAlign);
                //Cost Per Feet
                BigDecimal tCostFT = null;
                if(inquiryProduct.getThreading_Price_Ft() != null) {
                    tCostFT = inquiryProduct.getThreading_Price_Ft();
                }
                else {
                    tCostFT = null;
                }
                HSSFCell threadingCostPerFeet = createCellWithDouble(wb, tCostFT == null ? 0
                        : Float.parseFloat(tCostFT.toString()), 58, row2);
                setDecimalNumberStyle(wb, threadingCostPerFeet);
                CellUtil.setAlignment(threadingCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal tCostTon = null;
                if(inquiryProduct.getThreading_Price_Ton() != null) {
                    tCostTon = inquiryProduct.getThreading_Price_Ton();
                }
                else {
                    tCostTon = null;
                }
                HSSFCell threadingCostPerTon = createCellWithDouble(wb, tCostTon == null ? 0
                        : Float.parseFloat(tCostTon.toString()), 59, row2);
                setDecimalNumberStyle(wb, threadingCostPerTon);
                CellUtil.setAlignment(threadingCostPerTon, wb, leftAlign);
                
                //Coupling Values
                //Vendor
                String cVendor = null;
                if(inquiryProduct.getCoupling_Vendor() != null) {
                    cVendor = inquiryProduct.getCoupling_Vendor();
                }
                else {
                    cVendor = null;
                }
                HSSFCell couplingVendor = createCell(wb, cVendor == null ? "NA"
                        : cVendor, 60, row2);
                CellUtil.setAlignment(couplingVendor, wb, leftAlign);
                //Coupling Type
                String ccType = null;
                if(inquiryProduct.getCoupling_CouplingType() != null && !(inquiryProduct.getCoupling_CouplingType().isEmpty())) {
                    ccType = inquiryProduct.getCoupling_CouplingType();
                }
                else {
                    ccType = null;
                }
                HSSFCell couplingType = createCell(wb, ccType == null ? "NA"
                        : ccType, 61, row2);
                CellUtil.setAlignment(couplingType, wb, leftAlign);
                //Cost Per Feet
                BigDecimal cCostFT = null;
                if(inquiryProduct.getCoupling_Price_Ft() != null) {
                    cCostFT = inquiryProduct.getCoupling_Price_Ft();
                }
                else {
                    cCostFT = null;
                }
                HSSFCell couplingCostPerFeet = createCellWithDouble(wb, cCostFT == null ? 0
                        : Float.parseFloat(cCostFT.toString()), 62, row2);
                setDecimalNumberStyle(wb, couplingCostPerFeet);
                CellUtil.setAlignment(couplingCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal cCostTon = null;
                if(inquiryProduct.getCoupling_Price_Ton() != null) {
                    cCostTon = inquiryProduct.getCoupling_Price_Ton();
                }
                else {
                    cCostTon = null;
                }
                HSSFCell couplingCostPerTon = createCellWithDouble(wb, cCostTon == null ? 0
                        : Float.parseFloat(cCostTon.toString()), 63, row2);
                setDecimalNumberStyle(wb, couplingCostPerTon);
                CellUtil.setAlignment(couplingCostPerTon, wb, leftAlign);
                
                //Mechanical Connection Values
                //Vendor
                String mVendor = null;
                if(inquiryProduct.getMechanicalConnection_Vendor() != null) {
                    mVendor = inquiryProduct.getMechanicalConnection_Vendor();
                }
                else {
                    mVendor = null;
                }
                HSSFCell mcVendor = createCell(wb, mVendor == null ? "NA"
                        : mVendor, 64, row2);
                CellUtil.setAlignment(mcVendor, wb, leftAlign);
                //Cost Per Feet
                BigDecimal mechCostFT = null;
                if(inquiryProduct.getMechanicalConnection_Price_Ft() != null) {
                    mechCostFT = inquiryProduct.getMechanicalConnection_Price_Ft();
                }
                else {
                    mechCostFT = null;
                }
                HSSFCell mcCostPerFeet = createCellWithDouble(wb, mechCostFT == null ? 0
                        : Float.parseFloat(mechCostFT.toString()), 65, row2);
                setDecimalNumberStyle(wb, mcCostPerFeet);
                CellUtil.setAlignment(mcCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal mechCostTon = null;
                if(inquiryProduct.getMechanicalConnection_Price_Ton() != null) {
                    mechCostTon = inquiryProduct.getMechanicalConnection_Price_Ton();
                }
                else {
                    mechCostTon = null;
                }
                HSSFCell mcCostPerTon = createCellWithDouble(wb, mechCostTon == null ? 0
                        : Float.parseFloat(mechCostTon.toString()), 66, row2);
                setDecimalNumberStyle(wb, mcCostPerTon);
                CellUtil.setAlignment(mcCostPerTon, wb, leftAlign);
                
                //Thread Protector Values
                //Vendor
                String tpVendor = null;
                if(inquiryProduct.getThreadProtector_Vendor() != null) {
                    tpVendor = inquiryProduct.getThreadProtector_Vendor();
                }
                else {
                    tpVendor = null;
                }
                HSSFCell protectorVendor = createCell(wb, tpVendor == null ? "NA"
                        : tpVendor, 67, row2);
                CellUtil.setAlignment(protectorVendor, wb, leftAlign);
                //Thread Protect Type
                String tpType = null;
                if(inquiryProduct.getThreadProtector_ProtectType() != null) {
                    tpType = inquiryProduct.getThreadProtector_ProtectType();
                }
                else {
                    tpType = null;
                }
                HSSFCell protectorType = createCell(wb, tpType == null ? "NA"
                        : tpType, 68, row2);
                CellUtil.setAlignment(protectorType, wb, leftAlign);
                //Cost Per Feet
                BigDecimal tpCostFT = null;
                if(inquiryProduct.getThreadProtector_Price_Ft() != null) {
                    tpCostFT = inquiryProduct.getThreadProtector_Price_Ft();
                }
                else {
                    tpCostFT = null;
                }
                HSSFCell protectorCostPerFeet = createCellWithDouble(wb, tpCostFT == null ? 0
                        : Float.parseFloat(tpCostFT.toString()), 69, row2);
                setDecimalNumberStyle(wb, protectorCostPerFeet);
                CellUtil.setAlignment(protectorCostPerFeet, wb, leftAlign);
                //Cost Per Ton
                BigDecimal tpCostTon = null;
                if(inquiryProduct.getThreadProtector_Price_Ton() != null) {
                    tpCostTon = inquiryProduct.getThreadProtector_Price_Ton();
                }
                else {
                    tpCostTon = null;
                }
                HSSFCell protectorCostPerTon = createCellWithDouble(wb, tpCostTon == null ? 0
                        : Float.parseFloat(tpCostTon.toString()), 70, row2);
                setDecimalNumberStyle(wb, protectorCostPerTon);
                CellUtil.setAlignment(protectorCostPerTon, wb, leftAlign);
                
                //Totals Values
                //Total Cost of Good per Ton
                BigDecimal costGoodPerTon = null;
                if(inquiryProduct.getCostType_CostTonTotal() != null) {
                    costGoodPerTon = inquiryProduct.getCostType_CostTonTotal();
                }
                else {
                    costGoodPerTon = null;
                }
                HSSFCell totalCostofGoodTon = createCellWithDouble(wb, costGoodPerTon == null ? 0
                        : Float.parseFloat(costGoodPerTon.toString()), 71, row2);
                setDecimalNumberStyle(wb, totalCostofGoodTon);
                CellUtil.setAlignment(totalCostofGoodTon, wb, leftAlign);
                //Total Cost of Good Per Feet
                BigDecimal costGoodPerFt = null;
                if(inquiryProduct.getCostType_CostTotal() != null) {
                    costGoodPerFt = inquiryProduct.getCostType_CostTotal();
                }
                else {
                    costGoodPerFt = null;
                }
                HSSFCell totalCostofGoodFeet = createCellWithDouble(wb, costGoodPerFt == null ? 0
                        : Float.parseFloat(costGoodPerFt.toString()), 72, row2);
                setDecimalNumberStyle(wb, totalCostofGoodFeet);
                CellUtil.setAlignment(totalCostofGoodFeet, wb, leftAlign);
                //Profit Per Feet
                BigDecimal profitFt = null;
                if(inquiryProduct.getCostType_ProfitToAdd() != null) {
                    profitFt = inquiryProduct.getCostType_ProfitToAdd();
                }
                else {
                    profitFt = null;
                }
                HSSFCell profitPerFeet = createCellWithDouble(wb, profitFt == null ? 0
                        : Float.parseFloat(profitFt.toString()), 73, row2);
                setDecimalNumberStyle(wb, profitPerFeet);
                CellUtil.setAlignment(profitPerFeet, wb, leftAlign);
                //Profit Per Ton
                BigDecimal profitTon = null;
                if(inquiryProduct.getCostType_ProfitToAdd_Ton() != null) {
                    profitTon = inquiryProduct.getCostType_ProfitToAdd_Ton();
                }
                else {
                    profitTon = null;
                }
                HSSFCell profitPerTon = createCellWithDouble(wb, profitTon == null ? 0
                        : Float.parseFloat(profitTon.toString()), 74, row2);
                setDecimalNumberStyle(wb, profitPerTon);
                CellUtil.setAlignment(profitPerTon, wb, leftAlign);
                //Quoted Cost of Good Per Ton
                BigDecimal qCostGoodPerTon = null;
                if(inquiryProduct.getCostType_QuotedCostOfGood_Ton() != null) {
                    qCostGoodPerTon = inquiryProduct.getCostType_QuotedCostOfGood_Ton();
                }
                else {
                    qCostGoodPerTon = null;
                }
                HSSFCell quotedCostofGoodPerTon = createCellWithDouble(wb, qCostGoodPerTon == null ? 0
                        : Float.parseFloat(qCostGoodPerTon.toString()), 75, row2);
                setDecimalNumberStyle(wb, quotedCostofGoodPerTon);
                CellUtil.setAlignment(quotedCostofGoodPerTon, wb, leftAlign);
                //Quoted Cost of Good Per Feet
                BigDecimal qCostGoodPerFt = null;
                if(inquiryProduct.getCostType_QuotedCostOfGood() != null) {
                    qCostGoodPerFt = inquiryProduct.getCostType_QuotedCostOfGood();
                }
                else {
                    qCostGoodPerFt = null;
                }
                HSSFCell quotedCostofGoodPerFeet = createCellWithDouble(wb, qCostGoodPerFt == null ? 0
                        : Float.parseFloat(qCostGoodPerFt.toString()), 76, row2);
                setDecimalNumberStyle(wb, quotedCostofGoodPerFeet);
                CellUtil.setAlignment(quotedCostofGoodPerFeet, wb, leftAlign);
                //Price of Pipe per Ton Yard
                BigDecimal pipePrice = null;
                if(inquiryProduct.getPipePriceTonYard() != null) {
                    pipePrice = inquiryProduct.getPipePriceTonYard();
                }
                else {
                    pipePrice = null;
                }
                HSSFCell pipePriceTonYard = createCellWithDouble(wb, pipePrice == null ? 0
                        : Float.parseFloat(pipePrice.toString()), 77, row2);
                setDecimalNumberStyle(wb, pipePriceTonYard);
                CellUtil.setAlignment(pipePriceTonYard, wb, leftAlign);
                
                rowNo++;
            }
        }
        for (int i = 0; i <= 78; i++) {
                sheet.setColumnWidth(i, 6000);
        }
        
        createAllBorders(wb, sheet, 0, rowNo - 1, 0, 77);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            wb.write(out);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Core.storeFileDocumentContent(getContext(), FileDocumentParameter1.getMendixObject(),
                new ByteArrayInputStream(out.toByteArray()));
        return true;
    }
    // END EXTRA CODE
}
---------------------------------------------------------------------

Let me know if I have missed anything in the code.

Thanks in advance.

answered
0

Is the Java action from the Excel Export module from the AppStore? If so, please update this module. If not, it will be hard for us to help. We do not know how this got implemented, so your best bet would be to contact the developer who created your custom Java action.

answered