www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - XLS Files

reply Zarathustra <adam.chrapkowski gmail.com> writes:
Is there easy way of to get access to *.xls files.
To particular cells in sheets.
I need to read some data from spreadsheet straight to my program.
Thanks in advance.
Aug 18 2008
next sibling parent Henning Hasemann <hhasemann web.de> writes:
Zarathustra <adam.chrapkowski gmail.com> wrote:
 Is there easy way of to get access to *.xls files.
 To particular cells in sheets.
 I need to read some data from spreadsheet straight to my program.
 Thanks in advance.
Under linux there are catdoc tools that can transform xls files into CSV (plain text, comma-separeted-values) which are easily parsable. No idea how to access such stuff under windows but I'd guess there should be a more elegant way there, at least if excel is installed on the machine that runs your program. Sorry if this doesn't help you ;) Henning -- GPG Public Key: http://pgpkeys.pca.dfn.de/pks/lookup?op=get&search=0x30C7FC378DB14BE5
Aug 18 2008
prev sibling parent reply Max Samukha <samukha voliacable.com.removethis> writes:
On Mon, 18 Aug 2008 03:35:52 -0400, Zarathustra
<adam.chrapkowski gmail.com> wrote:

Is there easy way of to get access to *.xls files.
To particular cells in sheets.
I need to read some data from spreadsheet straight to my program.
Thanks in advance.
As you can access COM objects from D, you could use Automation or whatever they call it now.
Aug 18 2008
parent reply Zarathustra <adam.chrapkowski gmail.com> writes:
Max Samukha Wrote:

 On Mon, 18 Aug 2008 03:35:52 -0400, Zarathustra
 <adam.chrapkowski gmail.com> wrote:
 
Is there easy way of to get access to *.xls files.
To particular cells in sheets.
I need to read some data from spreadsheet straight to my program.
Thanks in advance.
As you can access COM objects from D, you could use Automation or whatever they call it now.
Reply to Max Samukha: Could you tell me where can I find more information about this way?
Aug 19 2008
next sibling parent Carl Clark <carlclark lavabit.com> writes:
Try these (I'm not a COM developer, but these might get you started):
http://msdn.microsoft.com/en-us/library/ms221375.aspx
http://msdn.microsoft.com/en-us/library/aa272254%28office.11%29.aspx 
(lists Automation objects, from a high-level [VBA] point of view; 
adaptation should be possible, if a little tricky)

HTH

On 2008-08-19 01:10, Zarathustra spoke thusly:
 Max Samukha Wrote:
 
 On Mon, 18 Aug 2008 03:35:52 -0400, Zarathustra
 <adam.chrapkowski gmail.com> wrote:

 Is there easy way of to get access to *.xls files.
 To particular cells in sheets.
 I need to read some data from spreadsheet straight to my program.
 Thanks in advance.
As you can access COM objects from D, you could use Automation or whatever they call it now.
Reply to Max Samukha: Could you tell me where can I find more information about this way?
Aug 19 2008
prev sibling parent reply yidabu <yidabu.spam gmail.com> writes:
using DWin on Windows:
http://www.dsource.org/projects/dwin/

here is an example from D China
http://bbs.d-programming-language-china.org/thread-797-1-1.html

import dwin.sys.win32.com.Core;
import dwin.sys.win32.com.Client;
import tango.io.Stdout;


void main()
{
    auto app = new DispatchObject("Excel.Application");
   
     app.set("Visible",1);                                
   
    auto vbooks = app.get("Workbooks");                  
    auto books = new DispatchObject(vbooks.pdispVal);
   
    auto vbook = books.get("Open", "d:\\200.xls");                    
\\打开此文件
    auto book = new DispatchObject(vbook.pdispVal);  
   
    auto vsheet = book.get("ActiveSheet");
    auto sheet = new DispatchObject(vsheet.pdispVal);
   
    auto vrange = sheet.get("Range", "A1");                         
\\设定单元格
    auto range = new DispatchObject(vrange.pdispVal);
   
    auto vvalue = range.get("Value");                                       
\\读该设定的单位格的值
     Stdout ( vvalue ).newline;       \\ vvalue
是Variant结构体,为什么可直接输出成员变量的值 呢?  
        
}



Zarathustra <adam.chrapkowski gmail.com> wrote:

 Max Samukha Wrote:
 
 On Mon, 18 Aug 2008 03:35:52 -0400, Zarathustra
 <adam.chrapkowski gmail.com> wrote:
 
Is there easy way of to get access to *.xls files.
To particular cells in sheets.
I need to read some data from spreadsheet straight to my program.
Thanks in advance.
As you can access COM objects from D, you could use Automation or whatever they call it now.
Reply to Max Samukha: Could you tell me where can I find more information about this way?
-- yidabu <yidabu.spam gmail.com> http://www.dsource.org/projects/dwin D 语言-中文(D Chinese): http://www.d-programming-language-china.org/ http://bbs.d-programming-language-china.org/ http://dwin.d-programming-language-china.org/ http://scite4d.d-programming-language-china.org/
Aug 19 2008
next sibling parent reply Zarathustra <adam.chrapkowski gmail.com> writes:
Reply to yidabu:
Great it's working.
Thanks a lot.

yidabu Wrote:

 
 using DWin on Windows:
 http://www.dsource.org/projects/dwin/
 
 here is an example from D China
 http://bbs.d-programming-language-china.org/thread-797-1-1.html
 
 import dwin.sys.win32.com.Core;
 import dwin.sys.win32.com.Client;
 import tango.io.Stdout;
 
 
 void main()
 {
     auto app = new DispatchObject("Excel.Application");
    
      app.set("Visible",1);                                
    
     auto vbooks = app.get("Workbooks");                  
     auto books = new DispatchObject(vbooks.pdispVal);
    
     auto vbook = books.get("Open", "d:\\200.xls");                    
\\打开此文件
     auto book = new DispatchObject(vbook.pdispVal);  
    
     auto vsheet = book.get("ActiveSheet");
     auto sheet = new DispatchObject(vsheet.pdispVal);
    
     auto vrange = sheet.get("Range", "A1");                         
\\设定单元格
     auto range = new DispatchObject(vrange.pdispVal);
    
     auto vvalue = range.get("Value");                                       
\\读该设定的单位格的值
      Stdout ( vvalue ).newline;       \\ vvalue
是Variant结构体,为什么可直接输出成员变量的值 呢?  
         
 }
 
 
 
 Zarathustra <adam.chrapkowski gmail.com> wrote:
 
 Max Samukha Wrote:
 
 On Mon, 18 Aug 2008 03:35:52 -0400, Zarathustra
 <adam.chrapkowski gmail.com> wrote:
 
Is there easy way of to get access to *.xls files.
To particular cells in sheets.
I need to read some data from spreadsheet straight to my program.
Thanks in advance.
As you can access COM objects from D, you could use Automation or whatever they call it now.
Reply to Max Samukha: Could you tell me where can I find more information about this way?
-- yidabu <yidabu.spam gmail.com> http://www.dsource.org/projects/dwin D 语言-中文(D Chinese): http://www.d-programming-language-china.org/ http://bbs.d-programming-language-china.org/ http://dwin.d-programming-language-china.org/ http://scite4d.d-programming-language-china.org/
Aug 20 2008
parent Max Samukha <samukha voliacable.com.removethis> writes:
That reminded me about an old win32 tutorial. Here is my favorite
part: http://www.relisoft.com/win32/olerant.html 
Aug 20 2008
prev sibling parent Ingo Oeser <ioe-news rameria.de> writes:
yidabu wrote:

 void main()
 {
     auto app = new DispatchObject("Excel.Application");
    
     app.set("Visible",1);
    
     auto vbooks = app.get("Workbooks");
     auto books = new DispatchObject(vbooks.pdispVal);
    
     auto vbook = books.get("Open", "d:\\200.xls");                    
     auto book = new DispatchObject(vbook.pdispVal);
    
     auto vsheet = book.get("ActiveSheet");
     auto sheet = new DispatchObject(vsheet.pdispVal);
    
     auto vrange = sheet.get("Range", "A1");                         
     auto range = new DispatchObject(vrange.pdispVal);
    
     auto vvalue = range.get("Value");                                     
     Stdout ( vvalue ).newline;
 }
Wow! That example really shows the simplifications possible with auto! Looking up those type chains alone would have taken half an hour! I'm really amazed! Best Regards Ingo Oeser
Aug 24 2008