• Post Reply Bookmark Topic Watch Topic
  • New Topic

Convert .txt to excel in java  RSS feed

 
prithvi pandey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have a txt file which i need to convert into excel.
Problem m facing is in parsing of the file ... the correct format i need in excel.
I am attaching both .txt file and its corresponding sample excel file.
please anyone suggest me the logic or the best practice for this conversion.
Thanks in advance .

sample txt file :

interfaces {
ge-0/1/0 {
per-unit-scheduler;
vlan-tagging;
mtu 4142;
hold-time up 30000 down 0;
unit 103 {
description CPC_OM;
vlan-id 103;
family inet {
address 10.34.86.130/26 {
vrrp-group 103 {
virtual-address 10.34.86.129;
priority 250;
preempt {
hold-time 120;
}
accept-data;
}
}
}
}
unit 111 {
description NOC_OSS;
vlan-id 111;
family inet {
address 10.34.86.85/29 {
vrrp-group 111 {
virtual-address 10.34.86.84;
priority 250;
preempt {
hold-time 120;
}
accept-data;
}
}
}
}
unit 210 {
description 3G_IUCS_CP;
vlan-id 210;
family inet {
address 10.50.15.194/30;
}
}
unit 211 {
description 3G_IUCS_UP;
vlan-id 211;
family inet {
address 10.50.15.202/30;
}
}
unit 212 {
description Allaha_3G_SS7;
vlan-id 212;
family inet {
address 10.50.18.2/30;
}
}
unit 213 {
description Allaha_3G_UP;
vlan-id 213;
family inet {
address 10.50.18.10/30;
}
}

}

Sample excel file : PFA


Output.PNG
[Thumbnail for Output.PNG]
 
Tim Moores
Saloon Keeper
Posts: 3834
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For parsing a well-defined structured text format I recommend to write a lexer grammar; JFlex is a library I've used successfully for that.

Once that's in place, the Apache POI library is an excellent way to create Excel files.

Note sure what this has to do with JSP, though.
 
prithvi pandey
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While inserting HyperLink to excel file using HSSFsheet and HSSFcell, m getting this undefined error :

The method setHyperlink(HSSFHyperlink) is undefined for the type HSSFCell

i m using apache-poi-2.5 libraries.
please suggest which version supports setHyperlink() method.
 
Tim Moores
Saloon Keeper
Posts: 3834
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
POI 2.5 has been obsolete for 10 years. Switch to the latest released version and see if you have better luck. Also read the javadocs of that method to see if there's anything else you need to know in order to use it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!