B4J Question Excel copy and paste

I am trying to copy a block of cells in a sheet to another location in the same sheet

I understand that I can copy using readrange but I don't know how to paste the results to a block yet, I am assuming I will just paste to the top left cell of required destination

However before I get that far I have come across something I just don't understand

The first line of code will run but the second won't

Any ideas?

B4X:
Dim LastEOI As XLReaderResult = xl.Reader.ReadRange(ExcelDirectory, eoiFileName,"Sheet1!A1:A1000")
Dim result2 As XLReaderResult = xl.Reader.ReadRange(ExcelDirectory, eoiFileName, "Sheet!A1:J28")

The error is
java.lang.RuntimeException: Object should first be initialized (PoiSheet).
 
UPDATE:
I just saw the typo error missing the 1 in the second line, putting the one there does indeed allow it to run but the actual line causing my problem is this

B4X:
Dim result2 As XLReaderResult = xl.Reader.ReadRange(ExcelDirectory, TicketFileName, "rejectSheet!A1:J28")

The code up to this point is this
B4X:
Workbook2 = xl.CreateWriterFromTemplate(ExcelDirectory, RejectFileName)
Dim rejectSheet As XLSheetWriter = Workbook2.CreateSheetWriterByName("rejectSheet")
    
Dim result2 As XLReaderResult = xl.Reader.ReadRange(ExcelDirectory, TicketFileName, "rejectSheet!A1:J28") 'read specific range
result2.LogResult(True)
 
Last edited:
Upvote 0
Based on the error message there is no sheet named rejectSheet.

Yeah it doesn't make much sense
This is the sheet produced by this code
B4X:
            rejectSheet.PutString(xl.AddressOne("B", rl), "  " & Pl.Name)
            rejectSheet.PutString(xl.AddressOne("D", rl), "  " & Pl.Category)
            rejectSheet.PutString(xl.AddressOne("F", rl), Pl.email )'"Ticket already issued")
            rejectSheet.PutString(xl.AddressOne("H", rl), "  " & Pl.TicketNo)
            rejectSheet.PutString(xl.AddressOne("J", rl), "  " & Pl.pDate)[
/CODE]

So quite clearly it does exist, so the question is, what is wrong with line 4 that causes the POI error?


Any ideas?

[ATTACH type="full" alt="1677153638180.png"]139664[/ATTACH][ATTACH alt="1677153638180.png"]139664[/ATTACH]
 

Attachments

  • 1677153638180.png
    1677153638180.png
    19.3 KB · Views: 68
Upvote 0
Top