21#import "C:\Program Files (x86)\Microsoft Office\Root\VFS\ProgramFilesCommonX86\Microsoft Shared\OFFICE16\MSO.DLL"
22#import "C:\Program Files (x86)\Microsoft Office\Root\VFS\ProgramFilesCommonX86\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
23#import "C:\Program Files (x86)\Microsoft Office\root\Office16\excel.exe" rename(
"DialogBox",
"DialogBoxForExcel") rename( "RGB", "RGBForExcel")
54 bool Open(LPCTSTR lpszXlsxFile)
57 HRESULT r = m_pApp.CreateInstance(
"Excel.Application");
65 m_pWorkbook = m_pApp->Workbooks->Open(fn.
ReferBuffer());
95 m_pWorkbook.Release();
119 m_pSheet = m_pWorkbook->Sheets->Item[
CUnicode(lpszSheetName).ReferBuffer()];
120 return m_pSheet != NULL;
140 varCell =
CUnicode(lpszCellName).ReferBuffer();
141 m_pRange = m_pSheet->GetRange( varCell);
148 return m_pRange != NULL;
166 return m_pRange->GetBorders()->GetItem(index);
185 buf[0] =
'A' + (j - 1);
192 Excel::_ApplicationPtr m_pApp;
193 Excel::_WorkbookPtr m_pWorkbook;
194 Excel::_WorksheetPtr m_pSheet;
195 Excel::RangePtr m_pRange;
200 ::CoInitialize(NULL);
204 Excel::_ApplicationPtr pApp;
207 pApp.CreateInstance(
"Excel.Application");
215 Excel::_WorkbookPtr pWorkbook;
218 pWorkbook = pApp->Workbooks->Open(L
"C:\\Home\\Temp\\DDDDD\\Test\\Debug\\test.xlsx");
232 Excel::_WorksheetPtr pSheet = pWorkbook->Sheets->Item[L
"Sheet2"];
238 Excel::RangePtr pRang;
239 pRang = pSheet->GetRange( varCell);
240 pRang->NumberFormat =
"@";
242 pRang->Value2 =
"=A1+B1";
245 Excel::BorderPtr border;
246 border = pRang->GetBorders()->GetItem( Excel::xlEdgeTop );
247 border->LineStyle = (long)Excel::xlContinuous;
248 border = pRang->GetBorders()->GetItem( Excel::xlEdgeBottom);
249 border->PutLineStyle((
long)Excel::xlContinuous);
250 border = pRang->GetBorders()->GetItem( Excel::xlEdgeLeft);
251 border->LineStyle = (long)Excel::xlContinuous;
252 border = pRang->GetBorders()->GetItem( Excel::xlEdgeRight);
253 border->LineStyle = (long)Excel::xlContinuous;
254 border->PutWeight((
long)Excel::xlMedium);
256 pRang->Interior->Color = (long)RGB( 255, 0, 0 );
258 varCell = pRang->Value;
266 pRang = pSheet->Range[varCell];
267 _bstr_t bstrURL =
"http://homepage1.nifty.com/goldfish";
268 pSheet->Hyperlinks->Add( pRang, bstrURL);
Microsoft Office Excel コントロール補助
bool SelectWorksheet(LPCTSTR lpszSheetName)
[設定] カレントワークシート選択.
static CStr ColunmChar(INDEX idx)
[作成] カラム文字生成.
Excel::RangePtr GetRange(void)
[取得] レンジ取得.
bool SelectCell(LPCTSTR lpszCellName)
[設定] カレントセル名選択.
bool Close(bool isSave=true)
[設定] クローズ.
~CExcelControl(void)
デストラクタ
Excel::BorderPtr GetBorder(Excel::XlBordersIndex index)
[取得] ボーダー取得.
bool Open(LPCTSTR lpszXlsxFile)
[設定] オープン.
CStr GetCanonicalize(LPCTSTR path) const
[取得] 絶対パス作成.
const TYP * ReferBuffer(void) const
[取得] バッファ参照.
TNB::CStrT< WCHAR > CUnicode
UNICODE文字列クラス