Solusi kita nyedhiyakake API independen platform sing kuat. Gunakake API dokumen Mail merge kanggo ngembangake piranti lunak tingkat dhuwur kanggo platform C++. Iki minangka solusi piranti lunak sing kuat kanggo nggabungake template ing Word format lan PDF lan data saka sumber data khusus lan luwih ngekspor asil menyang DOCX, PDF, HTML lan format populer liyane nggunakake C++.
Pustaka Fast C++ kanggo nglakokake gabungan Mail karo Excel data.
Mail Merge SDK ngidini sampeyan ngisi cithakan Word nganggo data saka Excel lembar. Adhedhasar Mail Merge API, sampeyan bisa nggawe solusi piranti lunak dhewe nggunakake C++, sing ngidini sampeyan ngotomatisasi email saka Excel lan ngasilake laporan nganggo Excel data.
Kanggo Mail merge saka Excel menyang Word, cukup nindakake operasi Mail merge ing C++ lan ekspor asil menyang Word format sing didhukung.
Kanthi Mail merge API sing kuat, sampeyan bisa nggawe dokumen pribadi ing C++ mung nggunakake cithakan Word Merge lan data saka Excel.
Cara nggunakake Mail merge saka Excel:
Kanthi Mail merge API kasetyan dhuwur, sampeyan uga bisa nindakake operasi Mail merge nganggo Google Docs. Cukup download data sing dibutuhake ing Word format lan Excel, priksa manawa template Word ngemot kolom gabungan lan nindakake operasi gabungan Mail ing C++, padha karo algoritma sing diterangake ing bagean sadurunge.
Kanggo nyoba alat web Mail merge sing kuat iki, muat cithakan Word kanthi kolom gabungan khusus lan data saka Excel sing diowahi kaya sing kasebut ing ndhuwur. Sawise mbukak kode, ekspor asil menyang format apa wae nggunakake C++.
Conto ing ngisor iki nuduhake carane nindakake operasi Mail merge kanggo ngasilake Word dokumen ing C++:
dotnet add package Aspose.Words.Cpp
Nyalin
using namespace Aspose::Words;
using namespace Aspose::Cells;
auto doc = MakeObject<Document>(u"Input1.docx");
auto workbook = Factory::CreateIWorkbook(new String("Input2.xlsx"));
auto worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);
auto dataRange = worksheet->GetICells()->GetMaxDisplayIRange();
auto dataTable = worksheet->GetICells()->ExportArray(
0, 0, dataRange->GetRowCount(), dataRange->GetColumnCount());
auto customersDataSource = MakeObject<BaseOperations::CustomerMailMergeDataSource>(dataTable);
doc->get_MailMerge()->Execute(customersDataSource);
doc->Save(u"Output.docx");
class ExcelDataSource : public IMailMergeDataSource
{
public:
System::String convertCellsString(String cellsValue)
{
auto valCh = cellsValue.charValue();
auto convertedString = System::String(valCh);
String::deleteCharValue(valCh);
return convertedString;
}
System::String get_TableName() override
{
return nullptr;
}
CustomerMailMergeDataSource(
intrusive_ptr<Aspose::Cells::Systems::Array2D<Aspose::Cells::Systems::Object*>> data)
{
dataIn = data;
for (int i = 0; i < data->At(0)->GetLength(); i++) {
auto fieldName = data->GetValue(0, i)->ToString();
m.insert({ convertCellsString(fieldName), i });
i++;
}
mRecordIndex = 0;
}
bool GetValue(System::String fieldName, SharedPtr<System::Object>& fieldValue) override
{
auto value = dataIn->GetValue(mRecordIndex, m.at(fieldName))->ToString();
if (value == new String(""))
return false;
fieldValue = System::ObjectExt::Box<System::String>(convertCellsString(value));
return true;
}
bool MoveNext() override
{
mRecordIndex++;
return mRecordIndex < dataIn->GetLength();
}
SharedPtr<IMailMergeDataSource> GetChildDataSource(System::String tableName) override
{
return nullptr;
}
intrusive_ptr<Aspose::Cells::Systems::Array2D<Aspose::Cells::Systems::Object*>> dataIn;
std::unordered_map<System::String, int> m;
int mRecordIndex;
};
Ana telung opsi kanggo nginstal Aspose.Words for C++ kanggo lingkungan pangembang. Pilih salah siji sing cocog karo kabutuhan sampeyan lan tindakake pandhuan langkah demi langkah:
Sampeyan bisa nggunakake perpustakaan C++ iki kanggo nggawe piranti lunak ing Microsoft Windows, Linux lan macOS:
Yen sampeyan nggawe piranti lunak kanggo Linux utawa macOS, priksa informasi babagan katergantungan perpustakaan tambahan (fontconfig lan paket sumber terbuka mesa-glu) ing Dokumentasi Produk.
Sampeyan bisa nindakake operasi Mail merge kanggo format file liyane: