A cikin rayuwarmu ta yau da kullun, muna shaida kwararar bayanai kyauta kuma kowace rana mai wucewa, yana sa haɗin gwiwa ya zama mafi mahimmanci. Don haka, buƙatar ingantaccen tsarin sarrafa takardu bai taɓa bayyana ba. Ko kai ɗalibi ne da ke zazzagewa ta takaddun bincike, ƙwararren mai sarrafa rahotanni masu rikitarwa, ko ƙungiyar da ke aiki tare akan aiki, ikon haɗa [Takardun Magana] ba tare da wata matsala ba(https://docs.fileformat.com/word-processing/ ) yana tsaye a matsayin sifa mai mahimmanci. Saboda haka, wannan labarin ya zurfafa cikin mahimmancin buƙatar haɗa takaddun Kalma, yana bayyana fa’idodin da yake kawowa ga fannoni daban-daban na rayuwar zamani.
- API ɗin REST don Haɗa Fayilolin Kalma
- Haɗa Takardun Kalma zuwa ɗaya tare da C# .NET
- Haɗa Takaddun Kalma ta amfani da Umarnin CURL
API ɗin REST don Haɗa Fayilolin Kalma
Sauƙaƙe tsarin haɗa fayilolin Kalma ta amfani da Aspose.Words Cloud SDK don NET. Wannan SDK mai ƙarfi yana ba da mafita mara ƙarfi don haɗawa da haɗa takaddun Kalma da yawa cikin ingantaccen tsari da ƙwarewa. Bugu da ƙari, Cloud SDK yana ba da ingantaccen hanya don haɗa takaddun Kalma ba tare da wahalar sa hannun hannu ba.
Mataki na farko a cikin amfani da SDK shine ƙara ambaton sa zuwa maganin NET. Don haka, bincika ‘Aspose.Words-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin ‘Ƙara Kunshin’. Bugu da ƙari, da fatan za a ziyarci cloud dashboard kuma sami keɓaɓɓen shaidar abokin ciniki.
Haɗa Takardun Kalma zuwa ɗaya tare da C# .NET
Da fatan za a bi umarnin da aka bayar a ƙasa don haɗa takaddun kalmomi akan layi ta amfani da C# .NET.
// Don cikakkun misalai da fayilolin bayanai, da fatan za a je zuwa
https://github.com/aspose-words-cloud/aspose-words-cloud-dotnet
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// ƙirƙiri abin daidaitawa ta amfani da ClinetID da bayanan Sirrin Abokin ciniki
var config = new Aspose.Words.Cloud.Sdk.Configuration { ClientId = clientID, ClientSecret = clientSecret };
// fara misali WordsApi
var wordsApi = new WordsApi(config);
// Load da takaddar Kalma ta farko
using var firstDocuemnt = File.OpenRead("file-sample.docx");
// Load da daftarin kalma na biyu
using var secondDocuemnt = File.OpenRead("secondFile.docx");
// sunan resultant concatenated fayil
String resultantFile = "combined.docx";
// ƙirƙira bayanin fayil zuwa takaddar Kalma ta biyu
var FileReference = new FileReference(secondDocuemnt);
// Ƙirƙirar DocumentEntry abu mai ma'anar daftarin aiki na farko don aiki tare
var requestDocumentListDocumentEntries0 = new DocumentEntry()
{
FileReference = FileReference,
ImportFormatMode = "KeepSourceFormatting"
};
// Ƙirƙirar lissafin abu mai riƙe da abuEntry Document
var requestDocumentListDocumentEntries = new List<DocumentEntry>()
{
requestDocumentListDocumentEntries0
};
// Fara Misalin Lissafin Shigar da Takardun da aka ƙirƙira a sama
var requestDocumentList = new DocumentEntryList()
{
DocumentEntries = requestDocumentListDocumentEntries
};
// Ƙirƙiri buƙatun AppendDocument inda muka ayyana jerin takaddun da za a haɗa su da takaddar farko
var appendRequest = new AppendDocumentOnlineRequest(firstDocuemnt, requestDocumentList, destFileName: resultantFile);
// Kira API don haɗa takaddun Kalma akan layi
var responseCode = wordsApi.AppendDocumentOnline(appendRequest);
// buga saƙon nasara idan aikin haɗa takarda ya yi nasara
if (responseCode != null && responseCode.Equals("OK"))
{
Console.WriteLine("Combine Word document operation completed successfully !");
Console.ReadKey();
}
Yanzu, bari mu bincika wasu cikakkun bayanai masu alaƙa da snippet ɗin lambar da aka bayyana a sama.
var config = new Configuration { ClientId = clientID, ClientSecret = clientSecret };
WordsApi wordsApi = new WordsApi(config);
Da farko, ƙirƙiri misali na ‘WordsApi’ ajin inda muke wuce bayanan abokin ciniki azaman mahawara.
ar FileReference = new FileReference(secondDocuemnt);
Ƙirƙiri abu na FileReference inda muke samar da misalin rafi mai riƙe da takaddar Kalma ta biyu.
var requestDocumentListDocumentEntries0 = new DocumentEntry()
{
FileReference = FileReference,
ImportFormatMode = "KeepSourceFormatting"
};
Ƙirƙirar DocumentEntry abu inda muka wuce bayanin fayil na fayil ɗin kalma na biyu kuma saka don riƙe tsarin daftarin aiki.
var requestDocumentListDocumentEntries = new List<DocumentEntry>()
{
requestDocumentListDocumentEntries0
};
Ƙirƙiri misalin jeri inda muka wuce abin da aka ƙirƙira a baya.
var appendRequest = new AppendDocumentOnlineRequest(firstDocuemnt, requestDocumentList, destFileName: resultantFile);
Ƙirƙiri misali na AppendDocument inda muke samar da rafin fayil ɗin Word na farko, jerin takaddun da za a haɗa da sunan fayil ɗin sakamako azaman muhawara.
var responseCode = wordsApi.AppendDocumentOnline(appendRequest);
A ƙarshe, kira API don fara aikin haɗa takardu.
Haɗa Takaddun Kalma ta amfani da Umarnin CURL
Kware da haɗin gwiwa mai ƙarfi, yana ba ku damar haɗa takaddun Kalma da yawa ba tare da ɓata lokaci ba cikin guda ɗaya, fayil ɗin haɗin gwiwa ta amfani da haɗuwa mai ƙarfi na Aspose.Words Cloud da umarnin cURL. Ta hanyar ƙirƙira umarnin cURL wanda ke hulɗa tare da Aspose.Words Cloud API, yana kawar da ƙoƙarin da hannu na yin kwafin abun ciki kuma yana tabbatar da cewa takaddun ku da aka haɗa yana kiyaye tsarin sa, salo, da tsarin gaba ɗaya.
Yanzu, mataki na farko a cikin wannan hanyar shine samar da alamar samun damar JWT ta aiwatar da umarni mai zuwa:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Da zarar muna da alamar JWT, da fatan za a aiwatar da umarni mai zuwa don haɗa takaddun Kalma zuwa fitarwa guda ɗaya. Lura, umarni mai zuwa yana tsammanin duk fayilolin Kalma da shigar da su sun riga sun kasance a cikin ma’ajiyar gajimare.
curl -v -X PUT "https://api.aspose.cloud/v4.0/words/ComparisonResult.docx/appendDocument?destFileName=MergedFile.docx" \
-H "accept: application/json" \
-H "Authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{\"DocumentEntries\":[{\"Href\":\"SampleMailMergeTemplate.docx\",\"ImportFormatMode\":\"KeepSourceFormatting\"}],\"ApplyBaseDocumentHeadersAndFootersToAppendingDocuments\":true}"
Kammalawa
A ƙarshe, ikon haɗa fayilolin Word yana aiki azaman ginshiƙi na ingantaccen sarrafa takardu da haɗin gwiwa. Tare da hanyoyi guda biyu masu ƙarfi a hannunku - yin amfani da Aspose.Words Cloud SDK don NET da kuma amfani da yuwuwar umarnin cURL - kuna da sassauci don zaɓar hanyar da ta fi dacewa da ƙwarewar fasaha da abubuwan da kuke so. Duk da haka, duka hanyoyin biyu suna haifar da ingantaccen tsari da haɗin gwiwa, tabbatar da cewa takaddun ku da aka haɗa su kula da tsarinsu, salo, da ƙwarewarsu gabaɗaya.
Hanyoyin haɗi masu amfani
Labarai masu alaka
Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: