Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7798365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:58:57+00:00 2026-06-01T23:58:57+00:00

I have an Excel spreadsheet which is one sheet with a table and chart

  • 0

I have an Excel spreadsheet which is one sheet with a table and chart in it. What I need to do is add this to a PDF. The PDF API I am using does not support importing Excel documents so I wondered if there is any way from C++ to save/convert an Excel document to a Jpeg (or BMP)?

Just to add, obviously this has to be done in C++ as part of an existing application which creates PDFs every time it is run. I wouldn’t be asking the question if it was a one off that could just be done manually.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:58:58+00:00Added an answer on June 1, 2026 at 11:58 pm

    Well I have, after much effort and hair pulling, managed to answer my own question. Contrary to what was said in other answers, it is possible to save an Excel spreadsheet as Jpeg (although I have stuck to bitmap format as that’s good enough for me. It would be easy enough to convert to jpeg though). What I did via the Excel API was select the used range. From there, I copy this to the clipboard as a picture, then get the clipboard data and convert it to a picture object with an IPicture interface. From there, create a stream and copy this to the stream before saving this stream to file. The result is a bmp file with exactly the image I was after. Code sample below.

        CRange range = sheet.get_UsedRange();
    
        range.CopyPicture(Excel::xlScreen, Excel::xlBitmap);
    
        if (IsClipboardFormatAvailable(CF_BITMAP)) // just to be sure it copied
        {
            if (OpenClipboard(NULL) > 0)
            {
                // save clipboard as bmp
                HBITMAP hBitmap = (HBITMAP)GetClipboardData(CF_BITMAP);
    
                SaveBitmap(ps_filename, hBitmap, NULL);
    
                CloseClipboard();
            }
        }
    }
    
    bool CExcelDocument::SaveBitmap(LPCSTR filename, HBITMAP bmp, HPALETTE pal)
    {
        bool bReturn = false;
        PICTDESC pictdesc;
        LPPICTURE pPicture;
    
        ::ZeroMemory( &pictdesc, sizeof(pictdesc) );
        pictdesc.picType        = PICTYPE_BITMAP;
        pictdesc.bmp.hbitmap    = bmp;
        pictdesc.bmp.hpal       = pal;
        pictdesc.cbSizeofstruct = sizeof(PICTDESC);
    
        HRESULT hr = OleCreatePictureIndirect(&pictdesc, IID_IPicture, false, reinterpret_cast<void**>(&pPicture));
    
        if (!SUCCEEDED(hr))
            return false;
    
        LPSTREAM pStream;
        hr = CreateStreamOnHGlobal(0, true, &pStream);
    
        if (!SUCCEEDED(hr))
        {
            pPicture->Release();
            return false;
        }
    
        LONG lBytesRead = 0;
        DWORD lBytesWritten = 0;
        hr = pPicture->SaveAsFile(pStream, true, &lBytesRead);
    
        if (!SUCCEEDED(hr))
        {
            pStream->Release();
            pPicture->Release();
            return false;
        }
    
        HANDLE hFile = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
    
        if (!hFile)
        {
            return false;
        }
    
        HGLOBAL hMemory = 0;
        GetHGlobalFromStream(pStream, &hMemory);
        LPVOID pData = GlobalLock(hMemory);
    
        bReturn = !!WriteFile(hFile, pData, lBytesRead, &lBytesWritten, 0);
        bReturn &= (lBytesWritten == static_cast<DWORD>(lBytesRead));
    
        GlobalUnlock(hMemory);
        CloseHandle(hFile);
    
        pStream->Release();
        pPicture->Release();
    
        return bReturn;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an excel spreadsheet with 15 columns, one of which is EmailAddress and
I have a Excel Spreadsheet with lab data which looks like this: µg/L (ppb)
I have a scenario in which I have to query an excel sheet using
I have one Excel spreadsheet which has the following columns: Surname / First Name
I have an Excel 2003 Spreadsheet which reference other add-ins. The add-ins are installed
I have a web app which lets the user select the excel spreadsheet and
I have an Excel Spreadsheet like this id | data for id | more
I have one spreadsheet which has 5 sheets All the sheets share the same
I have an excel spreadsheet, with one of the columns in form of hyperlinks
I have a Excel spreadsheet of requirements created from ReqPro that I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.