pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Bishop <tbishop@pooka.otago.ac.nz>
To: 'Jeff Eckermann' <jeff_eckermann@yahoo.com>
To: 'Merlin Moncure' <merlin.moncure@rcsonline.com>
To: pgsql-odbc@postgresql.org
Subject: Re: excel and postgresql: tips and questions
Date: Wed, 10 Nov 2004 11:48:55 +1300
Message-ID: <1B2042CF7F6F@pooka.otago.ac.nz> (raw)
In-Reply-To: <20041109170542.38615.qmail@web20821.mail.yahoo.com>



> 
> Alternatively you could try interposing MS Access, i.e. 
> define your queries in an Access database, and use those 
> queries as the datasource for the Excel report.  

I would try using a web query instead of access.  Make a simple (password
protected!) cgi that executes arbitrary sql and returns a html table.

Then use a web query from excel.  From recording a macro, I see that you can
set the URL to be anything you want (from vb)

    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;http://www.otago.ac.nz/phonebook/surnamef.html";,
Destination:=Range( _
        "A10"))
        .Name = "surnamef"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlSpecifiedTables
        .WebFormatting = xlWebFormattingRTF
        .WebTables = "6"
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With

You should thus be able to pop any parameters or sql you want in the query
string.

The advantage of this method is that excel handles getting the data into the
worksheet.

And, you don't need to install Postgres odbc drivers on your deployment
machines.

I did do this with 2003.  I'm not sure if you can do this with earlier Excel
versions.


-Tim




view thread (4+ messages)

Message-ID: <1B2042CF7F6F@pooka.otago.ac.nz>
Permalink:  ../1B2042CF7F6F@pooka.otago.ac.nz/
Also on:    postgresql.org/message-id/1B2042CF7F6F@pooka.otago.ac.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: tbishop@pooka.otago.ac.nz, jeff_eckermann@yahoo.com, merlin.moncure@rcsonline.com
  Subject: Re: excel and postgresql: tips and questions
  In-Reply-To: <1B2042CF7F6F@pooka.otago.ac.nz>
  References: <20041109170542.38615.qmail@web20821.mail.yahoo.com> <1B2042CF7F6F@pooka.otago.ac.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox