Buɗe yuwuwar bayananku ta hanyar zurfafa cikin duniyar CSV zuwa PDF juyawa. ta amfani da .NET REST API. Mun san cewa bayani shine mabuɗin don yanke shawara, ikon canza fayilolin CSV zuwa tsarin PDF ya zama mafi mahimmanci fiye da kowane lokaci. Wannan labarin yana bincika dalilai masu tursasawa bayan buƙatar CSV zuwa fassarar PDF, yana ba da haske kan yadda wannan tsari ba kawai yana sauƙaƙe sarrafa bayanai ba har ma yana haɓaka samun dama, haɗin gwiwa, da ingantaccen aiki gabaɗaya. "
- NET Cloud SDK don CSV zuwa Juyin PDF
- Maida CSV zuwa PDF a cikin C#
- Tsarin CSV zuwa PDF ta amfani da Umarnin CURL
NET Cloud SDK don CSV zuwa Juyin PDF
Canja bayanan CSV zuwa fayilolin PDF ba tare da matsala ba ya zama iska tare da Aspose.Cells Cloud SDK don NET. Wannan SDK mai ƙarfi yana ba da cikakkiyar bayani don ayyuka masu alaƙa da Excel, kuma yayin da babban abin da ya fi mayar da hankali ya ta’allaka ne a cikin ma’auni na ma’auni na Excel, yana kuma ƙara ƙarfinsa don sauƙaƙe jujjuya fayilolin CSV zuwa tsarin PDF. Ta hanyar yin amfani da damar Cloud SDK, zaku iya sarrafa tsarin jujjuya da kyau cikin aikace-aikacen NET ku.
Yanzu, don amfani da SDK, da farko muna buƙatar bincika ‘Aspose.Cells-Cloud’ a cikin manajan fakitin NuGet kuma danna maɓallin ‘Ƙara Kunshin’. Na biyu, sami takaddun shaidar abokin ciniki daga dashboard ɗin girgije. Idan ba ku da asusun da ke akwai, kawai ƙirƙirar asusun kyauta ta bin umarnin da aka kayyade a cikin labarin saurin farawa.
Maida CSV zuwa PDF a cikin C#
Bari mu bincika haɗa kai tsaye da sauƙin amfani, wanda ke tabbatar da sauyawa daga CSV zuwa PDF cikin santsi da daidaito. Don haka, bari mu shiga cikin cikakkun bayanai na sauya bayanan tabuka cikin ingantaccen tsarin PDF wanda ake iya rarrabawa duk duniya ta amfani da C# .NET.
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
Da farko, ƙirƙiri wani abu na ajin CellsApi inda muke ƙaddamar da shaidar abokin ciniki azaman muhawara.
PostWorkbookSaveAsRequest postworkbookSaveAsRequest = new PostWorkbookSaveAsRequest()
Abu na biyu, ƙirƙiri misali na ‘PostWorkbookSaveAsRequest’ inda muka ƙididdige sunan shigar da fayil ɗin CSV, sunan sakamako na PDF da kaɗan na zaɓin zaɓi.
var response = cellsInstance.PostWorkbookSaveAs(postworkbookSaveAsRequest);
Kira API don fara aikin CSV zuwa PDF. Da zarar an yi nasarar aiwatar da lambar, ana adana sakamakon PDF a cikin ma’ajin gajimare.
// Don cikakkun misalai da fayilolin bayanai, da fatan za a je zuwa
https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
// Samu bayanan abokin ciniki daga https://dashboard.aspose.cloud/
string clientSecret = "4d84d5f6584160cbd91dba1fe145db14";
string clientID = "bb959721-5780-4be6-be35-ff5c3a6aa4a2";
// ƙirƙiri misalin CellsApi yayin wuce ClientID da ClientSecret
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
// sunan shigar da fayil CSV
string input_CSV = "source.csv";
// sunan resultant PDF daftarin aiki
string resultant_PDF = "resultant.pdf";
try
{
// karanta abun ciki na shigar da fayil CSV
var file = System.IO.File.OpenRead(input_CSV);
PostWorkbookSaveAsRequest postworkbookSaveAsRequest = new PostWorkbookSaveAsRequest()
{
name = input_CSV,
newfilename = resultant_PDF,
isAutoFitRows = true,
isAutoFitColumns = true
};
// fara aikin juyawa
var response = cellsInstance.PostWorkbookSaveAs(postworkbookSaveAsRequest);
// buga saƙon nasara idan tuba ya yi nasara
if (response != null && response.Equals("OK"))
{
Console.WriteLine("Successful conversion of CSV to PDF format !");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Tsarin CSV zuwa PDF ta amfani da Umarnin CURL
A matsayin madadin, yi amfani da fa’idar Aspose.Cells Cloud da umarnin cURL don haɓaka aikin sarrafa daftarin aiki tare da amintaccen bayani mai jujjuyawa. API ɗin REST ɗin mu yana sauƙaƙa tsarin juyawa ta hanyar madaidaiciyar umarnin cURL, inda zaku iya aika buƙatu zuwa ƙarshen ‘PostWorkbookSaveAs’, samar da hujjojin da ake buƙata kuma sami sakamakon PDF.
Mataki na farko a wannan hanyar shine samar da alamar samun damar JWT ta amfani da umarni mai zuwa:
curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=921363a8-b195-426c-85f7-7d458b112383&client_secret=2bf81fca2f3ca1790e405c904b94d233" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"
Mataki na gaba mai mahimmanci shine aiwatar da umarni mai zuwa don canza tsarin CSV zuwa tsarin PDF. Bayan juyawa, ana adana sakamakon PDF a cikin ma’ajin gajimare.
curl -v "https://api.aspose.cloud/v3.0/cells/{inputCSV}/SaveAs?newfilename={resultantFile}&isAutoFitRows=true&isAutoFitColumns=true&checkExcelRestriction=false" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"SaveFormat\": \"PDF\", \"ClearData\": true, \"CreateDirectory\": true, \"EnableHTTPCompression\": true, \"RefreshChartCache\": true, \"SortNames\": true, \"ValidateMergedAreas\": true}"
Sauya ‘shigarwarCSV’ tare da sunan shigar da fayil ɗin CSV da ke samuwa a cikin ma’ajiyar girgije, ‘resultantFile’ tare da sunan sakamakon fayil ɗin PDF da za a ƙirƙira a cikin ma’ajin gajimare da ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.
Kammalawa
A ƙarshe, ko kun zaɓi cikakkiyar damar Aspose.Cells Cloud SDK don NET ko kuma sassaucin da aka bayar ta umarnin cURL, canza CSV zuwa PDF bai taɓa samun sauƙi ba. Tare da SDK, masu haɓakawa na iya haɗa ƙaƙƙarfan bayani ba tare da ɓata lokaci ba cikin aikace-aikacen NET ɗin su, suna fa’ida daga manyan ayyuka masu alaƙa da Excel da haɓaka tallafi don CSV zuwa fassarar PDF. A gefe guda, umarnin cURL yana ba da madaidaicin hanya, tushen tushen gajimare, sauƙaƙe tsarin jujjuyawa tare da madaidaiciyar madaidaicin ƙarshen API.
Hanyoyin haɗi masu amfani
Labarai masu alaka
Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: