com.acesoft.aceoffix.excelreader
Class WorkbookPHP

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

public class WorkbookPHP
extends java.lang.Object

Representing an Excel document, WorkbookPHP class is used to read the data submitted by AceoffixCtrl with PHP code.

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

Version:
5.0
Author:
Acesoft Corporation

Constructor Summary
WorkbookPHP()
          Initializes a new instance of WorkbookPHP class.
 
Method Summary
 java.lang.String 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.
 void load(java.lang.String Input)
          Load the request stream with PHP code.
 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

WorkbookPHP

public WorkbookPHP()
Initializes a new instance of WorkbookPHP class. com.acesoft.aceoffix.excelreader.WorkbookPHP object can only be created in the page specified in the AceoffixCtrl.SaveDataPage.

Method Detail

load

public void load(java.lang.String Input)
          throws java.lang.Exception,
                 java.io.IOException
Load the request stream with PHP code.

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

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.

 $ip = GetHostByName($_SERVER['SERVER_NAME']);
 require_once("http://".$ip.":8080/JavaBridge/java/Java.inc");
 $wb = new Java("com.acesoft.aceoffix.excelreader.WorkbookPHP");
 $wb->load(file_get_contents("php://input"));
 $sheet1 = $wb->openSheet("Sheet1");
 $strCompanyName = $sheet1->openCell("CompanyName")->getValue();
 //Save the data to database.
 
 $wb->setCustomSaveResult("My custom result");
 echo $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:
WorkbookPHP.setCustomSaveResult().

close

public java.lang.String 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:
WorkbookPHP.setCustomSaveResult().

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

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.

 $ip = GetHostByName($_SERVER['SERVER_NAME']);
 require_once("http://".$ip.":8080/JavaBridge/java/Java.inc");
 $wb = new Java("com.acesoft.aceoffix.excelreader.WorkbookPHP");
 $wb->load(file_get_contents("php://input"));
 $strSubject = $wb.getFormField("EditSubject"); 
 // After you get the input text, you can save it to the database.
 
 echo $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