That is quite a long list there and some of them relate more to programming
technique than use of POI but they are all possible. It may be best to
tackle them one at a time to avoid your getting overwhelmed with the details
so here is one possible way to tackle removing the Summary sheet from a
workbook. This time, I have not written a completed class for you but simply
some code that you should be able to assemble into a class.
int sheetToDelete = -1;
java.io.File file = new File(".......");
java.io.FileInutStream fis = new FileInputStream(file);
org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(fis);
fis.close();
int numSheets = workbook.getNumberOfSheets();
for(int i = 0; i < numSheets; i++) {
org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt();
if(sheet.getSheetName().equals("Summary")) {
sheetToDelete = i;
break;
}
}
// The sheet may not have been found and in that case sheetToDelete
// will still hold minus one. Only if it holds a value greater than that
will
// the sheet have been found and we can delete it.
if(sheetToDelete > -1) {
workbook.removeSheetAt(sheetToDelete);
}
java.io.FileOutputStream fos = new FileOutputStream(file);
workbook.write(fos);
and that sort of thing should do the trick. Remember to test the code on a
copy of the workbook first just to make sure it behaves as you want.
Once you have this one sorted, let me know and we can tackle removing the
unwanted commas from those values. Before doing so however, I would ask you
use Excel and take a look at the cells containing the values in question to
see whether they do actually contain embedded commas or if someone has
simply applied a format to them so that the value appears like that.
Yours
Mark B
PS Make sure to spell the sheet's name correctly otherwise it will not be
found.
Luke_Devon wrote:
>
> Hi ,
>
>
> As per the POI API, I
> think it is possible to modify EXCEL work sheets as well. My new
> requirement I
> would like to describe you.
>
> 1. Before convert into CSV, there are few
> modifications to be done to the EXCEL sheets.
>
> 2.
>
> Cell C
>
> Country Unit
> ------- ----
> aaa a
> b
> c
> d
> |
> |
> n
>
> Country field always in column “C”. It is constant.
> As I mentioned in the sketch, there is "n" number of values in the
> UNITS field. But in the country field, "aaa" won’t repeat until “n”
> number of units terminates. Country will display only once. I need to fill
> other cells in country columns until end of n number of units. Like this,
> there
> are more countries to be filled in the worksheet. All are align on CELLC.
>
> --------------------
> Cell H
>
> Based on Cell H there is a value called
> "Sum”. Once this value found entire ROWneeded to be removed
> from the work sheet.
>
> -------------------------------------
> In the work sheet, there is few values with
> comma. Eg: 1,300. These values are randomly located in the work sheet. I
> wanted
> to remove ","(comma) from the values. Eg: 1300
>
> ------------------------------------------------------
> And also in the worksheet there is 2 sheets
> are available. One is "summery" other one is "Detail". I
> wanted to remove "Summery" sheet.
> I would like to make sure , can we do such modifications via POI ? If it
> is possible can I see some examples ?
>
> As I introduced my self , I am not a software engineer. but kind of a
> developer with PERL , PHP and shell scripting. I used those scripting
> languages to automate some process in UNIX boxes. Since I am a Telecom
> systems engineer i would be able to do such little developments.but very
> frankly I am not a hardcore java developer. But my requirement is based on
> java right now.
>
>
> Your help very much appreciate.
>
> Thanks in advance
> Luke
>
>
>
> Get your new Email address!
> Grab the Email name you've always wanted before someone else does!
> http://mail.promotions.yahoo.com/newdomains/aa/
>
--
View this message in context:
http://old.nabble.com/Modify-EXCEL-work-sheets-from-POI-tp28226105p28231045.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]