我正在使用 Visual C++ 2010 中的 Windows 窗体进行项目。我正在使用BasicExcel类。以下是相关代码:
我包括头文件:
#include "BasicExcel.hpp"
using namespace YExcel;
然后,当我按下按钮时,我让软件在单元格 1,4 处写入“Test str1”:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
//Code for Writing to Excel
BasicExcel x;
// Load a workbook with one sheet, write some test data at (1,4)
x.Load("TestFile.xlsx");
BasicExcelWorksheet* sheet = x.GetWorksheet("Sheet1");
BasicExcelCell* cell;
sheet->Cell(1,4)->SetString("Test str1");
}
当我这样做时,我收到以下错误:
1>Enter Loads.obj : error LNK2028: unresolved token (0A000020) "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell@BasicExcelWorksheet@YExcel@@$$FQAMPAVBasicExcelCell@2@II@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005A) "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell@BasicExcelWorksheet@YExcel@@$$FQAMPAVBasicExcelCell@2@II@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000021) "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString@BasicExcelCell@YExcel@@$$FQAMXPBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005B) "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString@BasicExcelCell@YExcel@@$$FQAMXPBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000022) "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet@BasicExcel@YExcel@@$$FQAMPAVBasicExcelWorksheet@2@PBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005C) "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet@BasicExcel@YExcel@@$$FQAMPAVBasicExcelWorksheet@2@PBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000023) "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load@BasicExcel@YExcel@@$$FQAM_NPBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005D) "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load@BasicExcel@YExcel@@$$FQAM_NPBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000024) "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel@YExcel@@$$FQAM@XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005E) "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel@YExcel@@$$FQAM@XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2028: unresolved token (0A000025) "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel@YExcel@@$$FQAM@XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Agricultural_Software.obj : error LNK2028: unresolved token (0A00005F) "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel@YExcel@@$$FQAM@XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel@YExcel@@$$FQAM@XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: __clrcall YExcel::BasicExcel::~BasicExcel(void)" (??1BasicExcel@YExcel@@$$FQAM@XZ)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString@BasicExcelCell@YExcel@@$$FQAMXPBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: void __clrcall YExcel::BasicExcelCell::SetString(char const *)" (?SetString@BasicExcelCell@YExcel@@$$FQAMXPBD@Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell@BasicExcelWorksheet@YExcel@@$$FQAMPAVBasicExcelCell@2@II@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: class YExcel::BasicExcelCell * __clrcall YExcel::BasicExcelWorksheet::Cell(unsigned int,unsigned int)" (?Cell@BasicExcelWorksheet@YExcel@@$$FQAMPAVBasicExcelCell@2@II@Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet@BasicExcel@YExcel@@$$FQAMPAVBasicExcelWorksheet@2@PBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: class YExcel::BasicExcelWorksheet * __clrcall YExcel::BasicExcel::GetWorksheet(char const *)" (?GetWorksheet@BasicExcel@YExcel@@$$FQAMPAVBasicExcelWorksheet@2@PBD@Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load@BasicExcel@YExcel@@$$FQAM_NPBD@Z) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: bool __clrcall YExcel::BasicExcel::Load(char const *)" (?Load@BasicExcel@YExcel@@$$FQAM_NPBD@Z)
1>Agricultural_Software.obj : error LNK2019: unresolved external symbol "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel@YExcel@@$$FQAM@XZ) referenced in function "private: void __clrcall Agricultural_Software::EnterLoads::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@EnterLoads@Agricultural_Software@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Enter Loads.obj : error LNK2001: unresolved external symbol "public: __clrcall YExcel::BasicExcel::BasicExcel(void)" (??0BasicExcel@YExcel@@$$FQAM@XZ)
1>C:\Users\Jake\Documents\Agricultural Software\Agricultural_Software\Release\Agricultural_Software.exe : fatal error LNK1120: 18 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我试图修复它,但我对链接知之甚少。如果有人能启发我,我将不胜感激。谢谢!