Apache Poi Problems setting up in command line
You can specify your apache-poi
jar as follow.
C:/demo/myprogram>javac -cp C:/project/jars/apache-poi.jar Main.java
C:/demo/myprogram>java -cp C:/project/jars/apache-poi.jar. Main
Here we specify the jar to classpath during the compilation and execution,in this way you will be able to access the apache-poi
classes.
If you want to add multiple jars you can use *
for that,
java -cp C:/project/jars/*. Main
How to make my path relative in selenium apache poi while I input my Excel file? and How to write the test result in excel after performing testing
Can you try like :
FileInputStream input=new FileInputStream(new File("TestCase.xls"));
In your code? I think it should work.
POI API - Reference to font by the path
You should use HSSFFont for that. Take a look at the API.
For example:
public class ChangeCellFontName {
public static void main(String[] args) throws Exception{
/* Create Workbook and Worksheet */
HSSFWorkbook my_workbook = new HSSFWorkbook();
HSSFSheet my_sheet = my_workbook.createSheet("Cell Font");
/* Get access to HSSFCellStyle */
HSSFCellStyle my_style = my_workbook.createCellStyle();
/* Create HSSFFont object from the workbook */
HSSFFont my_font=my_workbook.createFont();
/* Set the font name to Verdana */
my_font.setFontName("Verdana");
/* Also make the font color to RED */
my_font.setColor(HSSFFont.COLOR_RED);
/* attach the font to the style created earlier */
my_style.setFont(my_font);
/* Attach the new font to a cell */
/* Create a row in the sheet */
Row row = my_sheet.createRow(0);
/* Create a cell */
Cell cell = row.createCell(0);
cell.setCellValue("The font for this text would be Verdana");
/* Attach the style to the cell */
cell.setCellStyle(my_style);
}
}
This last example was taken from here. Also, another example.
Related Topics
Classcastexception When Casting to the Same Class
Non Resizable Window Border and Positioning
How to Connect Remote MySQL Database in Android Using Jdbc
Android Recyclerview Addition & Removal of Items
When to Use Generic Methods and When to Use Wild-Card
Does Spring @Transactional Attribute Work on a Private Method
Maximum Java Heap Size of a 32-Bit Jvm on a 64-Bit Os
Double Decimal Formatting in Java
How to Compare Two Double Values in Java
What's Java Hybrid - Applet + Application
Gson: How to Exclude Specific Fields from Serialization Without Annotations
How to Sort Map Values by Key in Java
Ssl Handshake Alert: Unrecognized_Name Error Since Upgrade to Java 1.7.0
How to Check If a File Is Open by Another Process (Java/Linux)
Can't Run Program with Processbuilder, Runs Fine from Command Line
Set Environment Variable in Shell Script/Access in Java Program