Apparently you can add an image using JExcel but it is not supported in the library. Can anyone solve this to add this reference using inline java code?
Example I have found using java below.
B4X:
package com.bethecoder.tutorials.jexcelapi.write;
import java.io.File;
import java.io.IOException;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.WritableImage;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
public class AddImageCellTest {
/**
* @param args
* @throws IOException
* @throws IOException
* @throws WriteException
* @throws BiffException
*/
public static void main(String[] args) throws IOException, WriteException {
//Creates a writable workbook with the given file name
WritableWorkbook workbook = Workbook.createWorkbook(new File("C:/JXL/AddImage.xls"));
WritableSheet sheet = workbook.createSheet("My Sheet", 0);
WritableImage image = new WritableImage(
2, 4, //column, row
6, 6, //width, height in terms of number of cells
new File("C:/JXL/google.png")); //Supports only 'png' images
sheet.addImage(image);
//Writes out the data held in this workbook in Excel format
workbook.write();
//Close and free allocated memory
workbook.close();
}
}
Note that the library name is Excel not jExcel (which is the B4J library). In B4J you can add images with jPOI library which replaced jExcel.
Try this code:
B4X:
Private Sub AddImage(sheet As WritableSheet, bmp As InputStream, col As Double, row As Double, _
width As Double, height As Double)
Dim wi As JavaObject
wi.InitializeNewInstance("jxl.write.WritableImage", Array(col, row, width, height, _
Bit.InputStreamToBytes(bmp)))
Dim jo As JavaObject = sheet
jo.RunMethod("addImage", Array(wi))
End Sub
Note that the library name is Excel not jExcel (which is the B4J library). In B4J you can add images with jPOI library which replaced jExcel.
Try this code:
B4X:
Private Sub AddImage(sheet As WritableSheet, bmp As InputStream, col As Double, row As Double, _
width As Double, height As Double)
Dim wi As JavaObject
wi.InitializeNewInstance("jxl.write.WritableImage", Array(col, row, width, height, _
Bit.InputStreamToBytes(bmp)))
Dim jo As JavaObject = sheet
jo.RunMethod("addImage", Array(wi))
End Sub