可以開worksheet, 寫入/讀取 int, floating
簡單的example 如下
int main(int argc, char* argv[])
{
const char title[][20]={{"mean"},{"median"},{"deviation"},{"row dev"},{"column dev"}};
BasicExcel exl;
BasicExcelWorksheet* sheet1;
char* pchar;
char* sname1="testsheet1";
char* sname2="testsheet2";
BasicExcelCell* cell;
int i;
exl.New(2);
pchar=exl.GetAnsiSheetName(0);
exl.RenameWorksheet((size_t)0,(const char*)sname1);
exl.RenameWorksheet((size_t)1,(const char*)sname2);
sheet1=exl.GetWorksheet((size_t)1);
for( i=0;i<5;i++){
cell=sheet1->Cell(0,i);
cell->Set(title[i]);
}
for(i=0;i<5;i++){
cell=sheet1->Cell(1,i);
cell->Set(i);
}
exl.SaveAs("AndrewEx.xls");
return 0;
}
另外發現一個 bug , 在存double 時會失去小數第二位, 假如值大於10000
加入一行code 可以解決
在 BasicExecelVC6.cpp line 5242 line
canStoreAsRKValue = false;
整個vc++ 6.0 的code project 放在
https://drive.google.com/file/d/0B8CM49ChRXAqczgydlhGZ1JURm8/edit?usp=sharing
參考內容
http://www.codeproject.com/Articles/13852/BasicExcel-A-Class-to-Read-and-Write-to-Microsoft
http://social.msdn.microsoft.com/Forums/zh-TW/6d4922fc-e070-4d03-b3c8-8072e6ed3f74/how-to-createopen-and-edit-excel-using-visual-c?forum=vcmfcatl
原始提供 檔案 (copy to personal google driver)
https://drive.google.com/file/d/0B8CM49ChRXAqOTBiemZmakRuLUE/edit?usp=sharing
文件
https://docs.google.com/document/d/1EwbG848Zd21rKvfIJbdTd2-LemMoiY9KlP-PCKSsAUg/edit?usp=sharing
沒有留言:
張貼留言