Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Apr 24, 2014 9:10 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Read value from a xls sheet.
PostPosted: Mon Apr 16, 2012 9:59 am 
Offline

Joined: Mon Jan 16, 2012 8:08 am
Posts: 161
Location: India
Hi All,
I have a .xls file and the file have two columns like name and age.Then how i read the the value from a xls file.Please tell me.

Thanks
Bimal.


Top
 Profile  
 
 Post subject: Re: Read value from a xls sheet.
PostPosted: Mon Apr 16, 2012 12:39 pm 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
Bimal wrote:
Hi All,
I have a .xls file and the file have two columns like name and age.Then how i read the the value from a xls file.Please tell me.

Thanks
Bimal.


Here's a function to save a listbox as an excel file

Sub saveAsExcelFile(extends source as listbox, file as folderItem)
dim output as BinaryStream
dim tmp as string
dim d as date
dim i,j as integer

if file=nil then return

output = file.CreateBinaryFile("excel")
if source.hasHeading then
for i=0 to source.columnCount-1
output.write source.heading(i)+chr(9)
next
output.write chr(13)
end if

for i=0 to source.listcount-1
for j=0 to source.columncount-1
output.write source.cell(i,j)+chr(9)
next
output.write chr(13)
next
output.close
End Sub


You can use a similar method in "reverse" to load an excel file to a listbox...hope it helps. notice the delimiters chr(9)(horizontal tab) and chr(13)(Carriage Return)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
 
 Post subject: Re: Read value from a xls sheet.
PostPosted: Mon Apr 16, 2012 2:15 pm 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
With our MBS Plugins you can read/write real excel files. Both older xls and newer xlsx files.

Maybe you simply watch this video:
http://www.mbsplugins.com/WriteInvoice.shtml

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
 
 Post subject: Re: Read value from a xls sheet.
PostPosted: Wed Apr 18, 2012 9:34 am 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
Does the save As Excel also open the file in excel?
I guess I can test it.... but thought I'd ask.

I need to be able to save as excel, export out and ideally pops open in excel wo having to hunt for the file... and preferably import from excel.

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
 
 Post subject: Re: Read value from a xls sheet.
PostPosted: Wed Apr 18, 2012 10:23 am 
Offline
User avatar

Joined: Sun Aug 12, 2007 10:10 am
Posts: 1086
Location: Boiling Springs, SC
torrid wrote:
Does the save As Excel also open the file in excel?
I guess I can test it.... but thought I'd ask.

I need to be able to save as excel, export out and ideally pops open in excel wo having to hunt for the file... and preferably import from excel.


Will make a saveasexcel and openasexcel example for you :-)

_________________
Matthew A. Combatti
Real Studio 2012 r1.2

Visit Xojo Developer's Spot!
Systems I Use:
Windows XP/Windows Vista/Windows Server 2008 r2/Windows 7/Windows 8
Mac OSX 10.5/Mac OSX 10.6/Mac OSX Server/Ubuntu/Debian/Suse/Red Hat/
Windows Server 2011/CentOS 5.4 /ReactOS/SimOS

~All Xojo Compatible~


Top
 Profile  
 
 Post subject: Re: Read value from a xls sheet.
PostPosted: Wed Apr 18, 2012 10:54 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
The code above creates CSV file. It does not care for text encoding.
And you have no formulas, no formatting and just one sheet.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
 
 Post subject: Re: Read value from a xls sheet.
PostPosted: Wed Apr 18, 2012 3:48 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
I have a saveasexcel function that works... just dumps it to a file.

In VB6 I had code that create and excel application object and it would open the file in Excel.

Also the RB routine I have works but the headers lost their formatting... I REplaceAll on ENdOfLine chars in headers but then when you open it you see just first word maybe two of the headers instead of them "auto fit" or "autowrapped"... some of the headers are 5 or 7 words I split them into lines so that all words can be seen at once "stacked"... not sure if this makes sense.

I found the Einhugar control for exporting to excel but I don't have time to implement it... it requires his core libraries and type lib just to even test the demo.... just don't have time for it... maybe later.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group