Link to home
Start Free TrialLog in
Avatar of Ritu Joshi
Ritu Joshi

asked on

how to wrtie "null" for every blank cell while converting excel to csv in java.

language: Java

 i have one bank statement  in xls format , which i already convert into csv format in java .  and display in jsp  ,but how user can recognized the amount is debit or credit because it come in one column i.e  amount . and  after edit  form jsp it will save in database , where two different column for debit and credit .....

Problem:  In excel File : there is two column Debit Amt. and credit Amount , but the transaction will be debit or credit , but when i convert into csv file ,  it not write null on blank cell . i

 used missing policy ,
 case Cell.CELL_TYPE_BLANK:
                                                                                               
                                  data.append("***" + ",");
                                    break;

 but it work on total blank column , not a every blank cell .

Kindly guide .Thanks  in advance .
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

What you should probably do is
a. attach sample spreadsheet
b. post handling code in code tags
And why transforming the slightly better format (Excel) into the worst (CSV)? Why not something more modern (XML, JSON)?

Then you mentioned transactions: What is your use-case/task?
Avatar of Ritu Joshi
Ritu Joshi

ASKER

@Ste5an - hi,  thanks for the comment, actually i have a module in which user will upload .xls file (bank Statment) and , it will display as report in jsp and then , user can edit data accordingly and then save to database . but when i convert in csv using java , it convert all the thing , but ignore the blank field , so the debit /credit column  sometime has value sometime not ..., example

SNO,PDATE,VDATE,CHQNO,DES,DEBIT,CREDIT,BAL,
31523,1.6.2018,2.06.2018,560003108969,To Clg BHARTI AIRTEL LIMITED,23242,16,44,03,453.26,
@Ste5an - hi,  thanks for the comment, actually i have a module in which user will upload .xls file (bank Statment) and , it will display as report in jsp and then , user can edit data accordingly and then save to database . but when i convert in csv using java , it convert all the thing , but ignore the blank field , so the debit /credit column  sometime has value sometime not ..., example

SNO,PDATE,VDATE,CHQNO,DES,DEBIT,CREDIT,BAL,
31523,1.6.2018,2.06.2018,560003108969,To Clg BHARTI AIRTEL LIMITED,23242,16,44,03,453.26,
it has  8 column , but value only 7 ? becuse it ignore balnk , i want it print null aginst blank cell  in csv .
So - you're converting it wrongly. You need to post your conversion code
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.