Results 1 to 10 of 10
Thread: Read range name from Excel
- 05-19-2018, 04:52 PM #1
Member
- Join Date
- Apr 2017
- Posts
- 10
- Rep Power
- 0
Read range name from Excel
Hi Guys,
I am total newbe but i have to know how to read named range in apache poi.
I am trying only to read value for named range.
I am using code like:
Java Code:public static void main(String[] args) throws IOException { // setup code String cname = "TestName"; org.apache.poi.ss.usermodel.Workbook wb = null; try { wb = WorkbookFactory.create(new File("C:\\Users\\admin\\Desktop\\Example Variable3.xlsm")); } catch (EncryptedDocumentException | InvalidFormatException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } int namedCellIdx = wb.getNameIndex("TestVariable"); System.out.println(namedCellIdx); org.apache.poi.ss.usermodel.Name aNamedCell = wb.getNameAt(namedCellIdx); System.out.println(aNamedCell); } }
Exception in thread "main" java.lang.IllegalArgumentException: Specified name index -1 is outside the allowable range (0..0).
Best,
JacekLast edited by jaryszek; 05-19-2018 at 04:56 PM.
- 05-19-2018, 04:56 PM #2
Member
- Join Date
- Apr 2017
- Posts
- 10
- Rep Power
- 0
Re: Read range name from Excel
And my output is:
Attachment 7369
- 05-19-2018, 05:41 PM #3
Member
- Join Date
- Apr 2017
- Posts
- 10
- Rep Power
- 0
Re: Read range name from Excel
In attachment please find my example workbook.
I wnat to read named Range "Test" and "TestVariable".
Best,
Jacek
- 05-20-2018, 11:08 AM #4
Member
- Join Date
- Apr 2017
- Posts
- 10
- Rep Power
- 0
Re: Read range name from Excel
Anyone?
Jacek
- 05-20-2018, 03:58 PM #5
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: Read range name from Excel
Normally, a few days is not too long to wait. But this forum has not been very active this year (not sure why). So you may need to try some other forums. But when cross-posting, let each forum know where you've posted as a courtesy to avoid duplication of responses.
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 05-20-2018, 05:13 PM #6
Member
- Join Date
- Apr 2017
- Posts
- 10
- Rep Power
- 0
Re: Read range name from Excel
Hi Jim,
thank you,
can you recommend some other java forums? :)
Best,
Jacek
- 05-20-2018, 07:14 PM #7
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: Read range name from Excel
Try https://coderanch.com
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 05-20-2018, 07:57 PM #8
Member
- Join Date
- Apr 2017
- Posts
- 10
- Rep Power
- 0
Re: Read range name from Excel
thank you Jim!
Strange, a lot of people is wathing this topic but nobody answers.
Best,
Jacek
- 05-21-2018, 07:22 PM #9
Re: Read range name from Excel
What happened when you tried this: https://poi.apache.org/apidocs/org/a...odel/Name.html
"It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013
- 05-21-2018, 08:51 PM #10
Member
- Join Date
- Apr 2017
- Posts
- 10
- Rep Power
- 0
Re: Read range name from Excel
thank you Guys,
problem solved here:
https://coderanch.com/t/694322/java/...ctured#3259050
Best,
Jacek
Similar Threads
-
Return a range of cells with Apache POI Java API, Excel and Java
By pri515 in forum Apache POIReplies: 0Last Post: 07-17-2014, 04:18 AM -
Read Password Protected Excel 2013 Files & Print Excel Comments in Java Apps
By sherazam in forum Java SoftwareReplies: 0Last Post: 02-21-2014, 11:04 AM -
Place Image to Excel Page Header & Selecting Range of Cells in Worksheet
By sherazam in forum Java SoftwareReplies: 0Last Post: 11-01-2013, 07:17 AM -
How to read from excel?
By ginger0001 in forum Apache POIReplies: 2Last Post: 04-02-2012, 10:50 AM -
Excel: How to sort a range?
By Chris_X in forum Java ServletReplies: 9Last Post: 11-22-2010, 01:24 PM
Bookmarks