C++ CLR 读取Worksheet名称


C++ CLR 读取Worksheet名称:

  1. // OpenXmlC.cpp : main project file.   
  2.   
  3. #include "stdafx.h"   
  4.   
  5. using namespace System;  
  6. using namespace System::Collections::Generic;  
  7. using namespace System::Linq;    
  8. using namespace DocumentFormat::OpenXml::Packaging;  
  9. using namespace DocumentFormat::OpenXml::Spreadsheet;  
  10.   
  11.   
  12. int main(array<System::String ^> ^args)  
  13. {  
  14.     SpreadsheetDocument^ ssd = SpreadsheetDocument::Open("C:\\Users\\v-yangxu\\Desktop\\ExcelTemplate11.xlsx",false);  
  15.     WorkbookPart^ wbp = ssd->WorkbookPart;  
  16.     Workbook^ wb = wbp->Workbook;  
  17.     Sheet^ sheet = Enumerable::FirstOrDefault(wb->Descendants<Sheet^>());  
  18.   
  19.     Console::WriteLine(sheet->Name);  
  20.     Console::ReadKey();  
  21.     return 0;  
  22. }  

相关内容

    暂无相关文章