Visua Basic created charts to jpg or bmp


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Visua Basic created charts to jpg or bmp

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Visua Basic created charts to jpg or bmp

    [Originally posted by Swati Shukla]

    Hi,

    I have a VB code that accesses Access database and creates charts. How do I save these charts as .jpg or .bmp format?

    Regards,
    Swati

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Visua Basic created charts to jpg or bmp

    [Originally posted by Pieter van Vuuren]

    If you create them using the Excel chart object, there is a method that allows you to save them as jpg's.

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Visua Basic created charts to jpg or bmp

    [Originally posted by Andrew Russell]

    Try this (from a microsoft example that I've hacked in the past):

    --
    < % @ Language=VBScript % >
    < %
    Option Explicit
    Response.Expires = -1
    Response.ContentType = "image/gif"

    'Page-level variables
    '--------------------
    Dim m_cn 'connection object
    Dim m_fso 'file system object
    Dim m_objBinaryFile 'BinaryFileStream object
    Dim m_sYear 'year of data desired (query string parameter)
    Dim cht 'Temp ref to a chart
    Dim sFullFileName 'Full path to temp file for exported GIF

    'Save the current chart to a GIF file with a temporary, unique filename
    set m_fso = CreateObject("Scripting.FileSystemObject")
    sFullFileName = Server.MapPath(".") & "\" & m_fso.GetTempName()
    m_cspace.ExportPicture sFullFileName, "gif", 550, 350

    'Use On Error Resume Next to make sure we eventually delete
    'the temporary GIF file even if something fails in the next couple
    'of functions
    on error resume next

    'The GIF file has been created. Return the contents of the GIF file as
    'binary data using the BinaryFileStream ActiveX DLL
    set m_objBinaryFile = server.CreateObject("BinaryFileStream.Object")
    Response.BinaryWrite m_objBinaryFile.GetFileBytes(CStr(sFullFileName))

    'Delete the GIF file since it is no longer needed
    m_objBinaryFile.DeleteFile CStr(sFullFileName)


    % >
    ----

    If you place this on a stand along page, it should kick off a streamed image.˙ I've used this before, but I don't know how it works.˙ I just copyed, pasted, and hacked on it until it functioned.˙ I have no idea if it is good code or not.

    Don't spend too much time hacking on this if it doesn't work.˙ It may or may not give you ideas.

    -Andrew

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Visua Basic created charts to jpg or bmp

    [Originally posted by Pieter van Vuuren]

    Follow this link, it will show you a KB article on how to stream a chart.

    http://support.microsoft.com/support/kb/articles/Q264/0/96.ASP

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Visua Basic created charts to jpg or bmp

    [Originally posted by Andrew Russell]

    Just a note on using the OWC microsoft DLL to do your charts.˙ With office 2000 it was illegal to use them unless you purchased a copy of Office 2000 for each web visitor (yeah right!).˙ I was going to warn you about this, but Microsoft seems to have changed their view for office XP.

    The new licensing and requirements for OWC (Office WEb Componoents) can be found here:

    http://www.microsoft.com/office/ork/xp/five/wgtb06.htm

    As well as the links to download them if you don't have Office XP installed on your machine.˙ As a side note, the page also says that they will not work in Netscape (Surprise!):

    The Office Web Components have the same system requirements as the rest of Office XP. The Office Web Components are supported for Internet Explorer 4.01 or later, running on Microsoft Windows 98, Windows NT 4.0, or Windows 2000. Because the Office Web Components rely on ActiveX© technology, HTML documents that contain Office Web Components do not run in Netscape Navigator.
    ˙

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center