Hi
I am developing a ordering system for my client. The products have to be split to different Excel Files when they meet a criteria. Thus I'm loading 1 Template and Writing two copies each with the individual data.
I'm loading a Readable Workbook with the following code
As you can see, I'm loading the some Template twice but using two different Readable Sheets. And then defining the Writable Workbook as follows.
Problem comes in when populating the Excel files. The first one is fine but I get an error on the second one. Please see code below.
I'm am getting the following Error Message and I have no clue???
No Clue Where the "27" comes from?
PLEASE HELP.
Regards Gerome
I am developing a ordering system for my client. The products have to be split to different Excel Files when they meet a criteria. Thus I'm loading 1 Template and Writing two copies each with the individual data.
I'm loading a Readable Workbook with the following code
B4X:
Dim A_ReadableWB As ReadableWorkbook
Dim A_ROrderSheet As ReadableSheet
A_ReadableWB.Initialize("/storage/emulated/0/Folder/Template/", "Template.xls")
A_ROrderSheet = A_ReadableWB.GetSheet(0)
Dim B_ReadableWB As ReadableWorkbook
Dim B_ROrderSheet As ReadableSheet
B_ReadableWB.Initialize("/storage/emulated/0/Folder/Template/", "Template.xls")
B_ROrderSheet = B_ReadableWB.GetSheet(0)
As you can see, I'm loading the some Template twice but using two different Readable Sheets. And then defining the Writable Workbook as follows.
B4X:
AFileName = "Order A"
BFileName = "Order B"
Dim A_WritableWB As WritableWorkbook
ICONWritableWB.Initialize2("/storage/emulated/0/Folder/Orders/", AFilename & ".xls",A_ReadableWB)
Dim A_WOrdersheet As WritableSheet
A_WOrdersheet = A_WritableWB.GetSheet(0)
Dim B_WritableWB As WritableWorkbook
Dim B_WritableWB.Initialize2("/storage/emulated/0/Folder/Orders/", BFileName & ".xls",B_ReadableWB)
Dim B_WOrdersheet As WritableSheet
B_WOrdersheet = B_WritableWB.GetSheet(0)
Problem comes in when populating the Excel files. The first one is fine but I get an error on the second one. Please see code below.
B4X:
SQL.Initialize("/storage/emulated/0/Folder/DataBase/", "DB.db", True)
Dim CursorProducts As Cursor
CursorProducts = SQL.ExecQuery("SELECT Code, Company, Description, Category, Units, PriceListA, PriceListB, PriceListC FROM Products")
Dim ACount As Int
Dim BCount As Int
ACount = BCount = 0
For i = 0 To FOrdersLV.GetSize - 1
Code = FOrdersLV.GetPanel(i).GetView(0)
QtyEdt = FOrdersLV.GetPanel(i).GetView(4)
For j = 0 To CursorProducts.RowCount - 1
CursorProducts.Position = j
If Code.text = CursorProducts.GetString("Code") Then
Company = CursorProducts.GetString("Company")
If Company = "A" Then
AVar = "True"
ACell.InitializeText(0,18 + ACount, QtyEdt.text)
ACount = ACount + 1
Else If Company = "B" Then
BVar = "True"
BCell.InitializeText(0,18 + BCount, QtyEdt.text)
B_WOrdersheet.AddCell(BCell)
BCount = BCount + 1 'Probably the cause of the error
End If
Next
Next
If AVar = "True" Then
A_WritableWB.Write 'No Problem Here
A_WritableWB.Close
Else
A_WritableWB.Close
End If
If BVar = "True" Then
B_WritableWB.Write 'Error Happens Here
B_WritableWB.Close
Else
B_WritableWB.Close
End If
I'm am getting the following Error Message and I have no clue???
B4X:
java.lang.ArrayIndexOutOfBoundsException: length=27; index=27
No Clue Where the "27" comes from?
PLEASE HELP.
Regards Gerome