Importing Object and/or Mixed (Object,String) arrays


#1

I’m having issues importing Object arrays and/or arrays containing mixed types (ie. Objects and Strings) into Excel using the Java API. One simple example is below. Should it be possible to import arrays of mixed types?

public static void importObjectArrayOfStrings(Worksheet worksheet){
	try{
		Object[] names = new Object[] { "laurence chen", "roman korchagin", "kyle huang" };
		Cells cells = worksheet.getCells();
		cells.importObjectArray(names, 0, 0, false);
		
	}catch(Exception e){
		System.out.println("Exception Caught:\n" + e);
		e.printStackTrace();
	}
}

#2

@dwayne.hubbard,

Thanks for the code segment and details.

I tested the following sample code with latest version/fix: Aspose.Cells for Java v19.8.x, it works fine and I do find any issue:
e.g
Sample code:

Workbook workbook = new Workbook();
		Worksheet worksheet = workbook.getWorksheets().get(0);
		
		try{
			Object[] names = new Object[] { "Tom", "John", "kelly", 1, 2, 2.8, 5.16, true, false };
			Cells cells = worksheet.getCells();
			cells.importObjectArray(names, 0, 0, false);
			
			workbook.save("f:\\files\\out1.xlsx");
			
		}catch(Exception e){
			System.out.println("Exception Caught:\n" + e);
			e.printStackTrace();
		} 

Could you share your code segment (runnable) where you find issue, we will check it soon.