C++新建xls表并写入数据

#include "BasicExcel.hpp"
using namespace YExcel;


int main(int argc, char* argv[])
{
	BasicExcel e;


	// Create a new workbook with 2 worksheets and write some contents.
	e.New(2);
	e.RenameWorksheet("Sheet1", "Test1");
	BasicExcelWorksheet* sheet = e.GetWorksheet("Test1");
	BasicExcelCell* cell;
	if (sheet)
	{
		for (size_t c = 0; c < 7; ++c)
		{
			cell = sheet->Cell(0, c);
			cell->Set((int)(c+1));
		}


		cell = sheet->Cell(1,0);
		cell->SetDouble(3.141592654);


		sheet->Cell(1, 6)->SetString("Test str1 Test str1 Test str1 Test str1 Test str1 Test str1 Test str1 Test str1 ");
		//sheet->Cell(2, 0)->SetString("Test str2");
		//sheet->Cell(2, 5)->SetString("Test str1");


		//sheet->Cell(4, 0)->SetDouble(1.1);
		//sheet->Cell(4, 1)->SetDouble(2.2);
		//sheet->Cell(4, 2)->SetDouble(3.3);
		//sheet->Cell(4, 3)->SetDouble(4.4);
		//sheet->Cell(4, 4)->SetDouble(5.5);


		//sheet->Cell(4, 4)->EraseContents();
	}
	e.SaveAs("e:\\example3.xls");


	
	return 0;
}
<pre name="code" class="cpp">BasicExcel.hpp源文件和头文件可以从此处下载
<a target=_blank href="http://www.codeproject.com/Articles/13852/BasicExcel-A-Class-to-Read-and-Write-to-Microsoft">点击打开链接</a>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值