com.acesoft.aceoffix.excelreader
Class Workbook

java.lang.Object
  extended by com.acesoft.aceoffix.excelreader.Workbook

public class Workbook
extends java.lang.Object

Representing an Excel document, Workbook class is used to read the data submitted by AceoffixCtrl.

Workbook is an important class. Workbook object contains the data submitted by AceoffixCtrl. If you need to extract data from Excel spreadsheet, you have to create Workbook object. com.acesoft.aceoffix.excelreader.Workbook object can only be created in the page specified in the AceoffixCtrl.SaveDataPage.

Version:
5.0
Author:
Acesoft Corporation

Constructor Summary
Workbook(HttpServletRequest request, HttpServletResponse response)
          Initializes a new instance of Workbook class.
 
Method Summary
 void close()
          Closes the Workbook object and returns a success message for saving.
 java.lang.String getFormField(java.lang.String name)
          Gets the value of the Form field specified in the page with AceoffixCtrl.
 java.util.ArrayList<Sheet> getSheets()
          Gets the Sheet collection submitted by AceoffixCtrl.
 Sheet openSheet(java.lang.String sheetName)
          Opens the specified worksheet and returns a Sheet object.
 void setCustomSaveResult(java.lang.String value)
          Sets the custom saving result defined by developer.
 void showPage(int width, int height)
          Pops up a custom dialog box in browser to show the saving result in HTML format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Workbook

public Workbook(HttpServletRequest request,
                HttpServletResponse response)
         throws java.lang.Exception,
                java.io.IOException
Initializes a new instance of Workbook class. com.acesoft.aceoffix.excelreader.Workbook object can only be created in the page specified in the AceoffixCtrl.SaveDataPage.

Throws:
java.lang.Exception
java.io.IOException
Method Detail

setCustomSaveResult

public void setCustomSaveResult(java.lang.String value)
Sets the custom saving result defined by developer.

The following example shows how to use the CustomSaveResult property.

 Workbook wb = new Workbook(request, response);
 Sheet sheet1 = wb.openSheet("sheet1");
 String strCompanyName = sheet1.openCell("CompanyName").getValue();
 //Save the data to database.
 
 wb.setCustomSaveResult("My custom result");
 wb.close();
 

Then, custom saving result can be got from the CustomSaveResult property of AceoffixCtrl with JavaScript.

 <script language="javascript" type="text/javascript">
     function SaveDocument() {
         document.getElementById("AceoffixCtrl1").SaveDocument();
         alert(document.getElementById("AceoffixCtrl1").CustomSaveResult);//You can determine the next code logic according to the value of CustomSaveResult.
     }
 </script>
 


getSheets

public java.util.ArrayList<Sheet> getSheets()
                                     throws java.io.IOException,
                                            java.lang.Exception
Gets the Sheet collection submitted by AceoffixCtrl.

Throws:
java.io.IOException
java.lang.Exception

openSheet

public Sheet openSheet(java.lang.String sheetName)
                throws java.io.IOException,
                       java.lang.Exception
Opens the specified worksheet and returns a Sheet object. If the specified worksheet exists, this method will return a Sheet object.

Parameters:
sheetName - The name of the Sheet. The Sheet name can be found on the Tab tag at the bottom of the worksheet.
Returns:
Returns the Sheet object.
Throws:
java.io.IOException
java.lang.Exception
See Also:
Sheet.openCell().

close

public void close()
           throws java.io.IOException
Closes the Workbook object and returns a success message for saving.

If the code for saving document executes successfully, you must call this method to close the Workbook object.

Throws:
java.io.IOException
See Also:
Sheet.openTable().

showPage

public void showPage(int width,
                     int height)
              throws java.io.IOException
Pops up a custom dialog box in browser to show the saving result in HTML format.

If you want to pop up a custom dialog box to show the saving result in HTML format, you should call this method. The message page shown in dialog box is the current SaveDataPage. By default, the SaveDataPage will display nothing. You can add friendly prompts in SaveDataPage.

Parameters:
width - The width of dialog box, in pixels.
height - The height of dialog box, in pixels.
Throws:
java.io.IOException
See Also:
Sheet.openTable() to learn how to use the ShowPage method to display a custom saving error to user.

getFormField

public java.lang.String getFormField(java.lang.String name)
                              throws java.io.IOException,
                                     java.lang.Exception
Gets the value of the Form field specified in the page with AceoffixCtrl.

When AceoffixCtrl is saving document, you can call this method to get the values of the Form fields specified in the page with AceoffixCtrl.

Note: To capture the value of the Form field, the Form field must contain a name attribute.

The Form field can be Input Box, Drop-down Box, Radio, Check Box, TextArea, Hidden Field etc..

The following example shows how to use GetFormField method to get the value of the Form field posted from the page with AceoffixCtrl.

 Workbook wb = new Workbook(request, response);
 String strSubject = wb.getFormField("EditSubject"); 
 //Save the obtained data to database.
 Sheet sheet1 = wb.openSheet("sheet1");
 String strCompanyName = sheet1.openCell("CompanyName").getValue();
 wb.close();
 

Parameters:
name - The name of the Form field.
Returns:
Returns the value of the Form field.
Throws:
java.io.IOException
java.lang.Exception