Created
September 19, 2013 19:50
-
-
Save rondinif/6628904 to your computer and use it in GitHub Desktop.
Test code for the issue exposed in: (Not able to view ComboBox in Excel using JXL API)[http://stackoverflow.com/questions/18780151/not-able-to-view-combobox-in-excel-using-jxl-api]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Test code for the issue exposed in: | |
* http://stackoverflow.com/questions/18780151/not-able-to-view-combobox-in-excel-using-jxl-api | |
* -jar jxl.jar | |
* [jxl 2.6.12 2009-10-26](http://jexcelapi.sourceforge.net/) | |
* javac 1.7.0_25 | |
*/ | |
package org.rondakit.jxl.tester; | |
import java.io.File; | |
import java.io.IOException; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Date; | |
import java.util.List; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
import jxl.*; | |
import jxl.read.biff.BiffException; | |
import jxl.write.*; | |
import jxl.write.biff.RowsExceededException; | |
/** | |
* @author Franco | |
*/ | |
public class JXLTester { | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
List<String> xlData = Arrays.asList("rocks", "my", "world"); | |
List<String> xlHeader = Arrays.asList("Head1", "Head2"); | |
try { | |
WritableWorkbook workbook = Workbook.createWorkbook(new File("c:\\temp\\output.xls")); // this line allocate a file of 0 byte: | |
WritableSheet writableSheet = workbook.createSheet("First Sheet", 0); | |
// ArrayList<String> arrList = new ArrayList<String>(); | |
ArrayList arrList = new ArrayList(); | |
arrList.add("DropDown1"); | |
arrList.add("DropDown2"); | |
arrList.add("DropDown3"); | |
WritableCellFeatures cellFeatures = null; | |
Label checkLabel = null; | |
for (int x = 0; x < xlData.size(); x++) { | |
for (int i = 0; i <= 14; i++) { | |
System.out.println("X:" + x + "I:" + i); | |
if (i > 9) { | |
checkLabel = new Label(i, x + xlHeader.size(), (String) arrList.get(0)); | |
cellFeatures = new WritableCellFeatures(); | |
cellFeatures.setDataValidationList(arrList); | |
checkLabel.setCellFeatures(cellFeatures); | |
writableSheet.addCell(checkLabel); | |
} | |
} | |
} | |
workbook.write(); | |
workbook.close(); | |
} catch (IOException ex) { | |
Logger.getLogger(JavaApplication4.class.getName()).log(Level.SEVERE, null, ex); | |
// } catch (BiffException ex) { | |
// Logger.getLogger(JavaApplication4.class.getName()).log(Level.SEVERE, null, ex); | |
} catch (WriteException ex) { | |
Logger.getLogger(JavaApplication4.class.getName()).log(Level.SEVERE, null, ex); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment