#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>