I am not able to open xlsx file created with groovy code
Hi,
i have soapui 5.6.0 version installed in my machine with windows 10.
I am trying to create an xlsx file with groovy.
I have these jar files in lib folder:
commons-codec-1.15.jar
commons-math3-3.0.jar
jxl-2.6.8.jar
poi-5.0.0.jar
poi-ooxml-5.0.0.jar
poi-ooxml-schemas-4.1.2.jar
stax-api-1.0-2.jar
xmlbeans-4.0.0.jar
My groovy code is:
import jxl.*
import jxl.write.*
WritableWorkbook workbook = Workbook.createWorkbook(new File("C:\\Users\\ivan\\temp\\test.xlsx"))
WritableSheet sheet = workbook.createSheet("Test1", 0)
//log.info(sheet1.isHidden())
Label label = new Label(0, 2, "Test, Rangee3"); //column=0=A,row=0=1
sheet.addCell(label);
Label label1 = new Label(2, 2, "Test2, Rangee3");
sheet.addCell(label1);
workbook.write()
workbook.close()
Result:
The test.xlsx file is created but i am not able to open it in microsoft excel 365
It says the format or extension is not valid.
I tried with java code and it says the same thing
i used this java code:
import java.io.*;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
public class CreateExcelFileExample1
{
public static void main(String[] args) throws FileNotFoundException, IOException
{
//creating an instance of Workbook class
Workbook wb = new HSSFWorkbook();
//creates an excel file at the specified location
OutputStream fileOut = new FileOutputStream("C:\\Users\\dtq1482\\Test_Douane\\nonConfInterne.xlsx");
//System.out.println("Excel File has been created successfully.");
wb.write(fileOut);
}
}
I agree there's something wrong with the latest poi version.
I use an old one: 3.13 version, but it works fine.
You can find it in attached files.