접기
#pragma warning ( disable : 4018 4786 )
#include "BasicExcelVC6.hpp"
int main(int argc, char* argv[])
{
// {
using namespace YExcel;
BasicExcel e;
e.New (1);
e.RenameWorksheet ("Sheet1", "Test1");
BasicExcelWorksheet* sheet = e.GetWorksheet ("Test1");
BasicExcelCell* cell;
if (sheet)
{
for (size_t c=0; c<4; ++c)
{
cell = sheet->Cell (0,c);
cell->Set ((int)c);
}
cell = sheet->Cell (1,3);
cell->SetDouble (3.141592654);
sheet->Cell(1,4)->SetString ("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 ("example.xls");
e.Load ("example.xls");
BasicExcelWorksheet* sheet1 = e.GetWorksheet ("Sheet1");
if (sheet1) {
size_t maxRows = sheet1->GetTotalRows ();
size_t maxCols = sheet1->GetTotalCols ();
cout << "Dimension of " << sheet1->GetAnsiSheetName () <<
" (" << maxRows << ", " << maxCols << ")" << endl;
printf(" ");
for (size_t c=0; c<maxCols; ++c) printf("%10d", c+1);
cout << endl;
for (size_t r=0; r<maxRows; ++r) {
printf("%10d", r+1);
for (size_t c=0; c<maxCols; ++c)
{
BasicExcelCell* cell = sheet1->Cell (r,c);
switch (cell->Type ())
{
case BasicExcelCell::UNDEFINED :
printf(" ");
break;
case BasicExcelCell::INT :
printf("%10d", cell->GetInteger ());
break;
case BasicExcelCell::DOUBLE :
printf("%10.6lf", cell->GetDouble ());
break;
case BasicExcelCell::STRING :
printf("%10s", cell->GetString ());
break;
}
}
cout << endl;
}
}
cout << endl;
// }
// printf("Hello World!\n");
return 0;
}
접기