Thread: Merging the cells of excel from vc++

  1. #1
    Registered User
    Join Date
    Jun 2006
    Location
    Singapore
    Posts
    18

    Merging the cells of excel from vc++

    Hi guys,

    I'm using the COM programming to output an excel file from vc++. I would like to merge the cells using vc++. is it possible?
    My excel format:
    Some lengthy description that stretch thru 6 cells.
    Header1 | Header2 | Header3 | Header4 | Header5 | Header6

    I would like to merge the cells of the lengthy description.

    Thanks.

  2. #2
    Registered User
    Join Date
    Jun 2006
    Location
    Singapore
    Posts
    18

    Using Macro

    I found the following solution while googling.
    So I reproduce the method to share with others who may have similar problem. Cheers.

    Code:
    //Merge cells for a range of cells:
    BOOL MyClass::MergeCells(long nColumnStart, long nRowStart, long nColumnEnd, long nRowEnd)
    {
    	VARIANTARG vargSelection;
    	if(!GetCellRange(&vargSelection, nColumnStart, nRowStart, nColumnEnd, nRowEnd))
    		return FALSE;
    
    	ClearAllArgs();
    	AddArgumentBool(NULL, 0, TRUE);
    	if (!ExlInvoke(vargSelection.pdispVal, L"MergeCells", NULL, DISPATCH_PROPERTYPUT, 0))
    		return FALSE;
    	
    	return TRUE;
    }
    For full coding, plz refer to:
    http://www.codeguru.com/cpp/data/mfc...le.php/c11745/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading Excel Row Cells A through J
    By CheyenneWay in forum C++ Programming
    Replies: 37
    Last Post: 03-17-2011, 08:00 AM
  2. Dissecting an Excel XML spreadsheet
    By desmond5 in forum C++ Programming
    Replies: 1
    Last Post: 05-22-2008, 04:32 PM
  3. Write/Read Excel Cells
    By rogster001 in forum C Programming
    Replies: 15
    Last Post: 02-26-2008, 04:54 AM
  4. excel spreadsheets / blank cells
    By xddxogm3 in forum Tech Board
    Replies: 3
    Last Post: 06-14-2005, 12:10 PM
  5. C++ Builder and Excel files
    By mfdemi in forum Windows Programming
    Replies: 3
    Last Post: 09-24-2004, 01:51 AM