|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.acesoft.aceoffix.excelreader.Sheet
public class Sheet
Sheet class represents a worksheet defined in Excel.
You can only call the Workbook.openSheet(String) method to get the Sheet object.
Method Summary | |
---|---|
java.util.ArrayList<Cell> |
getCells()
Gets the Cells named by DefinedName. |
java.lang.String |
getName()
Gets the name of the Sheet. |
java.util.ArrayList<Table> |
getTables()
Gets the Tables named by DefinedName. |
Cell |
openCell(java.lang.String cellAddress)
Opens the specified cell and returns a Cell object. |
Cell |
openCellByDefinedName(java.lang.String definedName)
Opens the cell with the specified name defined in Excel and returns a Cell object. |
Table |
openTable(java.lang.String rangeAddress)
Opens the specified table and returns a Table object. |
Table |
openTableByDefinedName(java.lang.String definedName)
Opens the table with the specified name defined in Excel and returns the Table object. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public java.lang.String getName() throws java.io.IOException
java.io.IOException
public java.util.ArrayList<Cell> getCells() throws java.io.IOException, java.lang.Exception
java.io.IOException
java.lang.Exception
public java.util.ArrayList<Table> getTables() throws java.io.IOException, java.lang.Exception
java.io.IOException
java.lang.Exception
public Cell openCell(java.lang.String cellAddress) throws java.lang.Exception, java.io.IOException
If the specified Cell exists, this method will return the Aceoffix.ExcelReader.Cell object.
The following code example shows how to use the OpenCell method to get the value of the specified cell.
Workbook wb = new Workbook(request, response); Sheet sheet1 = wb.openSheet("sheet1"); String strCompanyName = sheet1.openCell("D1").getValue(); String strProductName = sheet1.openCell("D2").getValue(); String strProductCode = sheet1.openCell("D3").getValue(); String strAddress = sheet1.openCell("F6").getValue(); //After you get the value, you can save them to the database. wb.close();
cellAddress
- The A1-style notation is defined in Microsoft Excel. For example: "A1".
Note: There is a limit that the maximum number of columns per worksheet is 676 and the maximum number of rows is 65,536 in Excel2003 and earlier versions. Please do not exceed the maximum number of columns when input the parameter of CellAddress.
java.lang.Exception
java.io.IOException
public Cell openCellByDefinedName(java.lang.String definedName) throws java.lang.Exception, java.io.IOException
The following code example shows how to use the openCellByDefinedName method to get the value of the specified cell.
Workbook wb = new Workbook(request, response); Sheet sheet1 = wb.openSheet("sheet1"); String strCompanyName = sheet1.openCellByDefinedName("CompanyName").getValue(); String strProductName = sheet1.openCellByDefinedName("ProductName").getValue(); String strProductCode = sheet1.openCellByDefinedName("ProductCode").getValue(); //After you get the value, you can save them to the database. wb.close();
The
- name defined in Excel can be a global name or a local name. This method will only be valid when the Cell has a DefinedName.
java.lang.Exception
java.io.IOException
public Table openTable(java.lang.String rangeAddress) throws java.lang.Exception, java.io.IOException
If the specified Table exists, this method will return the Aceoffix.ExcelReader.Table object.
The following code example shows how to use the OpenTable method to get the value of the specified table.
Workbook wb = new Workbook(request, response); Sheet sheet1 = wb.openSheet("Sheet1"); String strCompanyName = sheet1.openCell("CompanyName").getValue(); //Get the data of a cell Table table1 = sheet1.openTable("B5:F16");//Get the data of a table while (!table1.getEOF()) { String strValues = ""; if (!table1.getDataFields().getIsEmpty()){ for (int i = 0; i < table1.getDataFields().size(); i++) strValues = strValues + table1.getDataFields().get(i).getText() + " "; // Output the data to the current page. Typically, you can save them to the database. out.print(strValues + "<br>\r\n"); } table1.nextRow(); } table1.close(); out.print("table1.RowCount = " + table1.getRowCount()); wb.showPage(800, 600);// Pop up a HTML dialog to show the data of table. wb.close();
rangeAddress
- The A1-style notation is defined in Microsoft Excel. For example: A1:F8, it means a range of cells A1 through F8. The A1 cell is the cell whose row index is 1 and column index is 1. The F8 cell is the cell whose row index is 8 and column index is 6.
Note: There is a limit that the maximum number of columns per worksheet is 676 and the maximum number of rows is 65,536 in Excel2003 and earlier versions. Please do not exceed the maximum number of columns when input the parameter of RangeAddress.
java.lang.Exception
java.io.IOException
public Table openTableByDefinedName(java.lang.String definedName) throws java.lang.Exception, java.io.IOException
The following code example shows how to use the openTableByDefinedName to get the value of the specified table.
Workbook wb = new Workbook(request, response); Sheet sheet1 = wb.openSheet("sheet1"); //Get the data of a table Table table1 = sheet1.openTableByDefinedName("SalesInfo", 7, 9); while (!table1.getEOF()){ String strValues = ""; if (!table1.getDataFields().getIsEmpty()){ for (int i = 0; i < table1.getDataFields().size(); i++) strValues = strValues + table1.getDataFields().get(i).getValue() + " "; // Output the data to the current page. Typically, you can save them to the database. out.println(strValues + "<br>\r\n"); } table1.nextRow(); } table1.close(); out.println("table1.RowCount = " + table1.getRowCount()); wb.showPage(800, 600); // Pop up a HTML dialog to show the data of table. wb.close();
definedName
- The name defined in Excel can be a global name or a local name. This method will only be valid when the table has a DedinedName.
java.lang.Exception
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |