Втр, 28 Сен 2010, Cox, Ed писал(а):
> I successfully wrote a tool for running SQL queries on a server and dumping 
> the results into Excel (2007) spreadsheet using OLE Automation.  It works 
> great except for one thing...the xlutil.ijs script implements the xlwriter 
> verb to paste the data into the spreadsheet.  Thus a conflict occurs if I 
> want to use copy and paste on my PC while the tool is running.
> 
> In studying OLE Automation I found an example of programming via C# that 
> appears to write an array directly to a spreadsheet (see code fragment below):
>          // Create an array to multiple values at once.
>                  string[,] saNames = new string[5,2];
> 
>                  saNames[ 0, 0] = "John";
>                  saNames[ 0, 1] = "Smith";
>                  saNames[ 1, 0] = "Tom";
>                  saNames[ 1, 1] = "Brown";
>                  saNames[ 2, 0] = "Sue";
>                  saNames[ 2, 1] = "Thomas";
>                  saNames[ 3, 0] = "Jane";
>                  saNames[ 3, 1] = "Jones";
>                  saNames[ 4, 0] = "Adam";
>                  saNames[ 4, 1] = "Johnson";
> 
>         //Fill A2:B6 with an array of values (First and Last Names).
>                  oSheet.get_Range("A2", "B6").Value2 = saNames;

Something like this,

  wd 'psel ', xlauto
  wd 'oleget me osheet range ', y
  wd 'oleid me range'
  wd 'oleset me range value *', x

where 
x is the data to be set in clipboard format
     fields separated by TAB and rows separated by CRLF
y is the range coordinates for the block, 
     eg. 'A2:B6'
xlauto is invisible form for oleautomation
me is the oleid for excel application
osheet is the oleid for the active work sheet

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to