How to change font color of particular cell apache poi 3.9

You’re currently creating some of your cells twice, which is why it’s all going wrong Firstly, I’d suggest you move the cell style creation to nearer the top of your code. Remember – cell styles are scoped to a workbook, so don’t create one per cell! CellStyle style = wb.createCellStyle(); Font font = wb.createFont(); font.setColor(HSSFColor.HSSFColorPredefined.BLACK.getIndex()); … Read more

Reading from src/main/resources gives NullPointerException

FileInputStream will load a the file path you pass to the constructor as relative from the working directory of the Java process. getResourceAsStream() will load a file path relative from your application’s classpath. When you use .getClass().getResource(fileName) it considers the location of the fileName is the same location of the of the calling class. When … Read more

Converting JSON to XLS/CSV in Java [closed]

You could only convert a JSON array into a CSV file. Lets say, you have a JSON like the following : {“infile”: [{“field1″: 11,”field2″: 12,”field3”: 13}, {“field1″: 21,”field2″: 22,”field3”: 23}, {“field1″: 31,”field2″: 32,”field3”: 33}]} Lets see the code for converting it to csv : import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.json.CDL; import org.json.JSONArray; import … Read more

xls to csv converter

I would use xlrd – it’s faster, cross platform and works directly with the file. As of version 0.8.0, xlrd reads both XLS and XLSX files. But as of version 2.0.0, support was reduced back to only XLS. import xlrd import csv def csv_from_excel(): wb = xlrd.open_workbook(‘your_workbook.xls’) sh = wb.sheet_by_name(‘Sheet1’) your_csv_file = open(‘your_csv_file.csv’, ‘wb’) wr … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)