JackSparrow
Member
I am having a problem with possibly the logic of this code
I am trying to read and write from one excel file ( succesfuly) and write to a second one also, (moderate\qualified success)
The code I have is as follows
Now if I write the code like this
It does not write the auditsheet records. However If I write it like this
It will write one record in the correct place and correct file
Can anyone see what I am missing?
Do I need to close and re-open one of the files if I write the 2nd bit of code inside the loop?
I am trying to read and write from one excel file ( succesfuly) and write to a second one also, (moderate\qualified success)
The code I have is as follows
Process_Globals:
Private Workbook As XLWorkbookWriter
Private Workbook1 As XLWorkbookWriter
Sub Rtn:
xl.Initialize
Dim ReadExcel As XLReaderResult = xl.Reader.ReadSheetByIndex(Directy, Filname, 0)
Workbook = xl.CreateWriterFromTemplate(Directy, Filname)
Dim sheet As XLSheetWriter = Workbook.CreateSheetWriterByName("Sheet1")
Workbook1 = xl.CreateWriterFromTemplate(Directy, Filname1)
Dim auditSheet As XLSheetWriter = Workbook1.CreateSheetWriterByName("auditSheet")
Now if I write the code like this
B4X:
'Update EOI File
sheet.PutString(xl.AddressOne("I", i+2), TicketNo)
sheet.PutString(xl.AddressOne("J", i+2), DateBought)
' Do the Audit Report
auditSheet.PutString(xl.AddressOne("B", lc), OB(0)) ' Name
auditSheet.PutString(xl.AddressOne("D", lc), "Category")
auditSheet.PutString(xl.AddressOne("F", lc), email)
auditSheet.PutString(xl.AddressOne("H", lc), TicketNo)
auditSheet.PutString(xl.AddressOne("J", lc), "IssueDate")
lc=lc+1
End If
Next
Workbook.SaveAs(Directy, Filname, True)
Workbook1.SaveAs(Directy, Filname1, True)
It does not write the auditsheet records. However If I write it like this
B4X:
'Update EOI File
sheet.PutString(xl.AddressOne("I", i+2), TicketNo)
sheet.PutString(xl.AddressOne("J", i+2), DateBought)
End If
Next
' Do the Audit Report
auditSheet.PutString(xl.AddressOne("B", lc), OB(0)) ' Name
auditSheet.PutString(xl.AddressOne("D", lc), "Category")
auditSheet.PutString(xl.AddressOne("F", lc), email)
auditSheet.PutString(xl.AddressOne("H", lc), TicketNo)
auditSheet.PutString(xl.AddressOne("J", lc), "IssueDate")
lc=lc+1
Workbook.SaveAs(Directy, Filname, True)
Workbook1.SaveAs(Directy, Filname1, True)
It will write one record in the correct place and correct file
Can anyone see what I am missing?
Do I need to close and re-open one of the files if I write the 2nd bit of code inside the loop?