Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

vwarship/ExcelLibrary

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Excel Library

介绍

包装了 Excel 的 COM 接口。快速读取和写入大量数据。

功能

  • 创建 xls, xlsx 格式
ExcelApplication app;
ExcelWorkbook workbook = app.AddWorkbook();
workbook.SaveAs(filename, ExcelFileFormat::Xlsx);
workbook.Close();
  • 写入数据
const ULONG rowNum = 20;
const ULONG colNum = 10;
ExcelData excelData;
excelData.Create(rowNum, colNum);

for (ULONG row = 1; row <= rowNum; ++row)
{
	for (ULONG col = 1; col <= colNum; ++col)
	{
		_variant_t value((row - 1)*colNum + col);
		excelData.SetValue(row, col, value);
	}
}

ExcelApplication app;
ExcelWorkbook workbook = app.Open(filename);
ExcelWorksheet worksheet = workbook.GetWorksheet(_T("Sheet1"));
worksheet.SetValues(excelData);
workbook.Save();
workbook.Close();
  • 读取数据
ExcelData excelData;

ExcelApplication app;
ExcelWorkbook workbook = app.Open(filename);
ExcelWorksheet worksheet = workbook.GetWorksheet(_T("Sheet1"));
worksheet.GetValues(excelData);
workbook.Close();

for (ULONG row = 1; row <= excelData.GetRowNum(); ++row)
{
	for (ULONG col = 1; col <= excelData.GetColNum(); ++col)
	{
		_variant_t value;
		excelData.GetValue(row, col, value);
		std::cout << V_R8(&value) << '\t';
	}
	std::cout << std::endl;
}

About

Excel Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.