You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by ketan126 <ke...@gmail.com> on 2011/10/24 13:51:04 UTC

Retrieve Excel File name/path using Sheet object

Hi,

I m using apache poi 3.7 jar and was stuck at one place while designing the
functionality, would require expert guidance on same.

I am reading excel using foll sample code
workbook = WorkbookFactory.create(new FileInputStream(fileName));

After getting  org.apache.poi.ss.usermodel.Workbook object ,i get
org.apache.poi.ss.usermodel.Sheet object and i pass it some method where i
can apply logic.

All above works fine. 

During processing logic if there is any erroneous condition matched i need
to show user a message with excel file name or excel file path.
Now i need to retrieve excel file name or excel file path using
org.apache.poi.ss.usermodel.Sheet object as within the method i have access
only to Sheet object . Is there any way to retrieve the same using Sheet
object ,i had gone through org.apache.poi.ss.usermodel.Sheet class and was
able to retrieve workbook object using Sheet class getWorkbook object but
was not able to find a way to get Excel file name or excel file path.

Thanks in advance.

--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Retrieve-Excel-File-name-path-using-Sheet-object-tp4932272p4932272.html
Sent from the POI - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Re: Retrieve Excel File name/path using Sheet object

Posted by Nick Burch <ni...@alfresco.com>.
On Mon, 24 Oct 2011, ketan126 wrote:
> I m using apache poi 3.7 jar and was stuck at one place while designing the
> functionality, would require expert guidance on same.
>
> I am reading excel using foll sample code
> workbook = WorkbookFactory.create(new FileInputStream(fileName));

It's much more memory efficient to pass a File object rather than an 
inputstream. (You'll need to upgrade from 3.7 to get that though)

> Is there any way to retrieve the same using Sheet object ,i had gone 
> through org.apache.poi.ss.usermodel.Sheet class and was able to retrieve 
> workbook object using Sheet class getWorkbook object but was not able to 
> find a way to get Excel file name or excel file path.

Nope, instead simply pass the filename to your method along with the sheet

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org