Android Question using of 64 encoding & decoding

sufyan

Member
Licensed User
Longtime User
dear Eral
after i fail to insert image to excel to generate a report and i fail to use PDFwriter too . i have idea and i hope to help if i can do it or not .
my idea is to insert all data of my database to excel sheet with image which encoding to string . this excel sheet will have vba code to decoding the string to image and generate the report after the user open the worksheet .
is this idea work or not ???
 

sufyan

Member
Licensed User
Longtime User
erel
i start with encoding the image and store it on excel sheet , but the file not open on device and computer
B4X:
Dim su As StringUtils
Dim su1 As String
Dim newWorkbook As WritableWorkbook
newWorkbook.Initialize(File.DirDefaultExternal, "SIPC_INSPECTION.xls")
Dim sheet1 As WritableSheet
sheet1 = newWorkbook.AddSheet("Inspection list", 0)
'we create a special format for the headers
Dim cellFormat As WritableCellFormat
'add the data
Dim rowsFormat As WritableCellFormat
rowsFormat.Initialize
rowsFormat.HorizontalAlignment = rowsFormat.HALIGN_CENTRE
rowsFormat.VertivalAlignment = rowsFormat.VALIGN_CENTRE
rowsFormat.Initialize2(rowsFormat.FONT_ARIAL, 12, True, False, False,  rowsFormat.COLOR_GREEN)
Cursor1 = sql1.ExecQuery("SELECT *FROM cam where cam_code ='" & s_code & "'")
    For i=0 To Cursor1.RowCount -1
        Cursor1.Position =i
       
        su1=su.EncodeBase64 (Cursor1.GetBlob("cam_picture"))
        Msgbox (su1,"")
        Dim cell As WritableCell
        cell.InitializeText(0, i, Cursor1.GetString("cam_title") & " : " & Cursor1.GetString("cam_note"))
        'cell.InitializeText(1, i, su1 )
        cell.InitializeFormula(1, i, su1)
        'cell.SetCellFormat(rowsFormat)
        sheet1.AddCell(cell)
    Next
    Cursor1.Close
'Must call write and close to save the data.
newWorkbook.Write
newWorkbook.Close
 
Upvote 0

sufyan

Member
Licensed User
Longtime User
B4X:
Sub SaveTable_Click
    'first we create a writable workbook.
    'the target file should be a NEW file.
Dim su As StringUtils
Dim su1 As String
Dim newWorkbook As WritableWorkbook
newWorkbook.Initialize(File.DirDefaultExternal, "SIPC_INSPECTION.xls")
Dim sheet1 As WritableSheet
sheet1 = newWorkbook.AddSheet("Inspection list", 0)
'we create a special format for the headers
Dim cellFormat As WritableCellFormat
'add the data
Dim rowsFormat As WritableCellFormat
rowsFormat.Initialize
rowsFormat.HorizontalAlignment = rowsFormat.HALIGN_CENTRE
rowsFormat.VertivalAlignment = rowsFormat.VALIGN_CENTRE
rowsFormat.Initialize2(rowsFormat.FONT_ARIAL, 12, True, False, False,  rowsFormat.COLOR_GREEN)
Cursor1 = sql1.ExecQuery("SELECT *FROM cam where cam_code ='" & s_code & "'")
    For i=0 To Cursor1.RowCount -1
        Cursor1.Position =i
       
        su1=su.EncodeBase64 (Cursor1.GetBlob("cam_picture"))
        Msgbox (su1,"")
        Dim cell As WritableCell
        cell.InitializeText(0, i, Cursor1.GetString("cam_title") & " : " & Cursor1.GetString("cam_note"))
        cell.InitializeText(1, i, su1 )
        sheet1.AddCell(cell)
    Next
    Cursor1.Close
'Must call write and close to save the data.
newWorkbook.Write
newWorkbook.Close
Msgbox ("","")
End Sub
 
Upvote 0

sufyan

Member
Licensed User
Longtime User
erel
if you see the code , i change it to text . and if u check the code i add msgbox to show the encoding string . the msgbox show the text but the file when i open it on my computer or device , i cant open and show the msg on attached file
 

Attachments

  • New Bitmap Image.jpg
    New Bitmap Image.jpg
    293.6 KB · Views: 192
Upvote 0
Top