• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compatible tab files

 
Ranch Hand
Posts: 164
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have tried lots of different methods to achieve the end result which is a text file that is the same as that produced by microsoft excel 2007

initially i have an application that creates spreadsheets (xls) using the jxl library which works fine i then have to open the xls and save it as other types e.g. tab delimited, the aim is to do away with this necessary step and just create a text file directly and be able to save these files should i need to check anything they would need to be opened by excel
so i set about placing \t in the string by supply a string with it in it  like this   fileloader("anotherTest","abc\t"+"def");



the result is abc def written to the anotherTest file on the C drive. if you observe the results using microsoft word the tab is displayed as the little arrow as you might expect, however if you attempt to open the file with excel the data is displayed in one cell with a small question mark in between the two strings instead of two adjacent cells, i have also reversed the process by typing the data into two adjacent cells and saving it and then displaying in word only to see a perfect match so why does the java generated file not open in excel correctly?  

i have look at lots of examples and as yet none have shown me how to create the same type of file that excel creates

i need to have tab files that excel can read and a tab delimited file that can be uploaded to a website this is a simplified version as the real data occupies several columns on the spreadsheet


 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's first see if this has nothing to do with Java and only to do with Excel.  Create a text file using Notepad or any text editor that looks like this:

<tab> of course is the tab key.  Save it as test-tab.txt and then open it in Excel.  I get a wizard that steps me through importing the tab file.  Does yours work?
 
peter m hayward
Ranch Hand
Posts: 164
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply, no idea why it would not work, but it seems to be working fine now using the following format
title + tab + author + tab + tab + sellingPrice which places the items under the relevant column, however i have run into another problem
date2 + tab + tab + tab + tab+ ISBN  the tabs between date2 and the ISBN are not inserted any idea why?

the tab is a string = "\t";

 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using String#split() to parse the input string?  If so, can you post it and any relevant code around it?

If your parse line is this:

...then I would expect "title + tab + author + tab + tab + sellingPrice" to put title in column A, author in column B, nothing in column C, and sellingPrice in column D.  Is that what you get?  Is it what you want?

"date2 + tab + tab + tab + tab+ ISBN" would put date2 in column A, nothing in columns B-D, and ISBN in column E.
 
peter m hayward
Ranch Hand
Posts: 164
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well i spent hours trying to track this one down only to find there was nothing wrong with the code somehow when i pasted in the data i picked up a stray character so let this be a lesson to all copy and paste may come with a penalty if  you’re not careful thanks to all that have looked at this problem and tried to help
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

peter m hayward wrote:let this be a lesson to all copy and paste may come with a penalty if  you’re not careful



Amen to that. I gave you a cow for the lesson to all.
reply
    Bookmark Topic Watch Topic
  • New Topic