up

解决方案 »

  1.   

    画出单元格?单元格不是有吗?是给加边框吗?
    just like this:
    pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight);
    if (pBorder )
    {
    pBorder ->PutLineStyle (varLineStyle);
    pBorder ->PutWeight (varWeight);
    pBorder ->PutColorIndex (varColorIndex);
    }
    设置属性,哪种属性?多得啦哈.
    合并单元格:like following:
    IndexToString(iLeft ,iTop,tszRange);
    _bstr_t  leftRange =tszRange ;
    IndexToString(iRight ,iBottom,tszRange);
    _bstr_t  rightRange =tszRange ;

    Excel::RangePtr pRange  = pSheet ->GetRange (leftRange,rightRange);
    if (pRange)
    {
    pRange ->Merge ();
    }
      

  2.   

    画出单元格?单元格不是有吗?是给加边框吗?
    just like this:
    pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight);
    if (pBorder )
    {
    pBorder ->PutLineStyle (varLineStyle);
    pBorder ->PutWeight (varWeight);
    pBorder ->PutColorIndex (varColorIndex);
    }
    设置属性,哪种属性?多得啦哈.
    合并单元格:like following:
    IndexToString(iLeft ,iTop,tszRange);
    _bstr_t  leftRange =tszRange ;
    IndexToString(iRight ,iBottom,tszRange);
    _bstr_t  rightRange =tszRange ;

    Excel::RangePtr pRange  = pSheet ->GetRange (leftRange,rightRange);
    if (pRange)
    {
    pRange ->Merge ();
    }
      

  3.   

    GetBorders()-> 没有GetItem() 它
      

  4.   

    Excel::BorderPtr pBorder ;
    "GetBorders()-> 没有GetItem() 它"什么意思?不明白.
      

  5.   

    GetBorders() 返回值是IDispatch类型 它没有GetItem()成员函数
    你的pRange 是加的excel9.cpp里的Range 类定义的指针吗?
      

  6.   

    Excel::BorderPtr pBorder ;
    我编译不过去,你加了那个头文件
      

  7.   

    just a simple win32 console project.not use mfc. :)#include <ole2.h>
    #include <stdio.h>
    #pragma warning (disable:4146)
    #pragma warning (disable:4192)
    #pragma warning (disable:4049)#import "d:\Program Files\Microsoft Office\Office\MSO9.dll"
    #import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" no_namespace 
    #import "d:\Program Files\Microsoft Office\Office\MSWORD9.OLB" rename("ExitWindows","_ExitWindows")
    #import "d:\Program Files\Microsoft Office\Office\excel9.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") \
             rename("DocumentProperties", "DocumentPropertiesXL") exclude("IFont","IPicture")char* IndexToString(int row, int col, char *strResult)
    {
    if (row < 1 || col < 1 ||IsBadWritePtr(strResult,sizeof(char*)) )
    {
    return "";
    } if(col > 26)
    {
    sprintf(strResult, "%c%c%d",'A'+(col-1)/26-1, 'A'+(col-1)%26, row);
    }
    else
    {
    sprintf(strResult, "%c%d", 'A' + (col-1)%26, row);
    }
    return strResult;
    }
    int main(int argc, char* argv[])
    {
    VARIANT varItem;
    varItem.vt = VT_I4;
    varItem.intVal = 1;
        ::CoInitialize(NULL);
        CLSID clsid;
        CLSIDFromProgID(L"Excel.Application", &clsid);  Excel::_ApplicationPtr pApp;
    pApp .CreateInstance (clsid,NULL);
    pApp ->PutVisible (0,VARIANT_TRUE);
    Excel::_WorkbookPtr pWorkbook = pApp ->GetWorkbooks ()->Add ();//->Open (OLESTR("E:\\EXCEL\\module.xls"));// 
    Excel::_WorksheetPtr    pSheet    = pWorkbook ->GetWorksheets ()  ->GetItem (varItem);
    Excel::RangePtr     pRange    = pSheet ->GetRange(OLESTR("A1"));
    pRange ->Value2     = OLESTR("SOME");
    Excel::InteriorPtr  pInterior= pRange ->GetInterior ();
    varItem.intVal = 0xff0000;
    pInterior ->PutColor (varItem); TCHAR tszRange[32];
    IndexToString(2,2,tszRange);
    _bstr_t bstrRange (tszRange);
    pRange = pSheet ->Range [bstrRange] ;
    Excel::BorderPtr pBorder ;
    _variant_t varLineStyle ;
    _variant_t varWeight;
    _variant_t varColorIndex; varLineStyle .vt = VT_I4;
    varLineStyle.intVal = 1;//excel::xlContinuous  1 varWeight.vt        = VT_I4;
    varWeight.intVal = 2;//excel::xlThin 2 varColorIndex.vt    = VT_I4;
    varColorIndex.intVal= 1;
    int iAlign = 15;
    if (iAlign & 1 )//左边的边框
    {
    pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeLeft);
    if (pBorder)
    {
    pBorder ->PutLineStyle (varLineStyle);
    pBorder ->PutWeight (varWeight);
    pBorder ->PutColorIndex (varColorIndex);
    }
    pBorder = NULL;
    }
    if (iAlign & 2)//上边的边框
    {
    pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeTop);
    if (pBorder)
    {
    pBorder ->PutLineStyle (varLineStyle);
    pBorder ->PutWeight (varWeight);
    pBorder ->PutColorIndex (varColorIndex);
    }
    pBorder = NULL;
    }
    if (iAlign & 4)//右边的边框
    {
    pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeRight);
    if (pBorder )
    {
    pBorder ->PutLineStyle (varLineStyle);
    pBorder ->PutWeight (varWeight);
    pBorder ->PutColorIndex (varColorIndex);
    }
    pBorder = NULL;
    }
    if (iAlign & 8 )//下边的边框
    {
    pBorder = pRange ->GetBorders () ->GetItem (Excel::xlEdgeBottom);
    if (pBorder )
    {
    pBorder ->PutLineStyle (varLineStyle);
    pBorder ->PutWeight (varWeight);
    pBorder ->PutColorIndex (varColorIndex);
    }
    pBorder = NULL;
    }
    #if 0
    pSheet ->PrintPreview ();
    #endif
        ::CoUninitialize();
        return 0;
    }
      

  8.   

    嘿嘿,你说能不能PrintPreview ()呢.just change #if 0 to #if 1.
      

  9.   

    faint,你在stdafx.h里copy哪几个#include和#import,在对话框里放一个button,把main中间的东西copy出去.不就得了.
    不送我100分你就真不够意思.浪费我这么多口水.
    just a joke.not mind.haha.:)
      

  10.   

    我的msn是[email protected].
    公司不能上qq. :( 我哭,我的同学,我的...