0

I have developed a code which allows me to download an Excel file based on a prepared template that contains vba code and macro.

The code below allow me to create calendar workbook from template file.

        String nomFichierExcel = "D:\\Calendrier"+annee+"-"+versionFac+"-"+versionPrel+".xls"; 
        String filePath = "D:\\test3107\\test-calender-war\\CALWAS\\templateee.xls";                    
        WorkbookSettings ws = new WorkbookSettings() ;
        ws.setEncoding("Cp1252");
        Workbook workbook = Workbook.getWorkbook(new File(filePath),ws); 
        WritableWorkbook copy = Workbook.createWorkbook(new File(nomFichierExcel), workbook ); 

The problem is after downloading the Excel file I cannot find the vba code and module when I press ALT + F11, also when I open the file I get this as error message, but I can see data after clicking OK button.

File error: data may have been lost

2
  • If you want to download a file, no need to use jxl: it's just a file, we don't care what is inside (and there are other ways to download a file in Java). Apparently, if you try to open the file as a Workbook within jxl api, the macro is lost: not too surprising, as it has a specific format unrelated to worksheets, that is probably more difficult to parse: check in the documentation if it's supported.
    – user10307643
    Commented Aug 28, 2019 at 11:21
  • Note also that the library is ten years old, and to deal with Excel files I would rather suggest Apache POI (which seems to have some support for VBA).
    – user10307643
    Commented Aug 28, 2019 at 11:26

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.