A cikin yanayin ci gaban yanar gizon da ke tasowa koyaushe, buƙatar abun ciki mai ƙarfi da jan hankali na gani ya zama mafi bayyana fiye da kowane lokaci. Kamar yadda kasuwanci da masu haɓakawa ke neman sabbin hanyoyin gabatar da bayanai akan gidan yanar gizo, juyar da CSV (Wakafi-Separated Values) fayiloli zuwa [HTML](https: //docs.fileformat.com/web/html/) yana fitowa a matsayin mafita mai mahimmanci. Ta hanyar amfani da damar .NET REST API, za mu iya juya kimar bayanan jere zuwa abun ciki na HTML masu mu’amala da amsa. Wannan sauyi ba wai yana haɓaka sha’awar gani na bayanai kawai ba amma har ma yana ba da gudummawa ga ƙwarewar yanar gizo mai zurfi da mai amfani.
- API ɗin NET REST don CSV zuwa Canjin HTML
- Yadda ake Canza CSV zuwa HTML a C# .NET
- CSV zuwa Juyin Yanar Gizo ta amfani da Umarnin CURL
API ɗin NET REST don CSV zuwa Canjin HTML
Aspose.Cells Cloud SDK for .NET yana ba da fasalulluka da yawa, gami da sarrafa fayil ɗin Excel, tsarin juzu’i iri-iri, sarrafa bayanan tantanin halitta, tsara ginshiƙi, da dabara. lissafi. Don haka, ta hanyar amfani da ƙarfin ƙarfinsa, zaku iya canza fayil ɗin CSV cikin sauƙi zuwa shafin HTML.
Haɓaka ayyukan ku ta hanyar tabbatar da ingantaccen gudanarwa da gabatar da bayanai a cikin aikace-aikacen yanar gizo.
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.
Yadda ake Canza CSV zuwa HTML a C# .NET{#Yadda-Don Maida-CSV-zuwa-HTML-in-Csharp}
Bari mu bincika cikakkun bayanai kan yadda za mu iya juyar da CSV zuwa HTML ta kan layi 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.
SaveOptions saveOptions = new SaveOptions()
Na biyu, ƙirƙiri misali na SaveOptions inda muke ayyana tsarin fitarwa azaman HTML kuma mu saita siga don damfara abubuwan HTML.
PostWorkbookSaveAsRequest postworkbookSaveAsRequest = new PostWorkbookSaveAsRequest()
Na uku, ƙirƙiri misali na ‘PostWorkbookSaveAsRequest’ inda muka ƙididdige sunan shigar da fayil ɗin CSV, sunan sakamakon HTML da sauran sigogin zaɓi.
var response = cellsInstance.PostWorkbookSaveAs(postworkbookSaveAsRequest);
Kira API don fara canza CSV zuwa HTML. Da zarar an yi nasarar aiwatar da lambar, ana adana sakamakon HTML 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 HTML fayil
string resultant = "output.html";
try
{
// karanta abun ciki na shigar da fayil CSV
var file = System.IO.File.OpenRead(input_CSV);
// ƙirƙirar abu na SaveOptions inda muke ayyana tsarin fitarwa
SaveOptions saveOptions = new Aspose.Cells.Cloud.SDK.Model.SaveOptions()
{
// fitarwa format na fayil
SaveFormat = "HTML",
ClearData = true,
EnableHTTPCompression = true
};
// Ƙirƙiri Buƙatun Ajiye na PostWorkbook domin mu fara aikin juyawa
PostWorkbookSaveAsRequest postworkbookSaveAsRequest = new PostWorkbookSaveAsRequest()
{
// sunan shigar da Fayil CSV
name = input_CSV,
saveOptions = saveOptions,
// resultant sunan fayil
newfilename = resultant,
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 HTML file !");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
CSV zuwa Juyin Yanar Gizo ta amfani da Umarnin CURL
A matsayin hanya ta biyu, kuna iya la’akari da daidaita tsarin canza CSV zuwa HTML ta hanyar sauƙi na amfani da Aspose.Cells Cloud da umarnin cURL. Don haka, ta amfani da umarnin cURL, zaku iya aika buƙatu zuwa ƙarshen ƙarshen ‘PostWorkbookSaveAs’, saka fayil ɗin CSV da shigarwar da tsarin fitarwa da ake so azaman ‘HTML’. Wannan hanyar kuma tana tabbatar da daidaito da inganci, yayin da ake canza danyen bayanan CSV zuwa abun cikin HTML mai gani da mu’amala.
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"
Yanzu, da fatan za a aiwatar da umarni mai zuwa don canza CSV zuwa tsarin HTML na Yanar Gizo. Bayan jujjuyawar, sakamakon HTML fayil ana adana shi a cikin ajiyar girgije.
curl -v "https://api.aspose.cloud/v3.0/cells/{myInput}/SaveAs?newfilename={outputFile}&isAutoFitRows=true&isAutoFitColumns=true&checkExcelRestriction=false" \
-X POST \
-H "accept: application/json" \
-H "authorization: Bearer {accessToken}" \
-H "Content-Type: application/json" \
-d "{ \"SaveFormat\": \"html\", \"CachedFileFolder\": \"string\", \"ClearData\": true, \"CreateDirectory\": true, \"EnableHTTPCompression\": true, \"RefreshChartCache\": true, \"SortNames\": true, \"ValidateMergedAreas\": true}"
Sauya ‘myInput’ tare da sunan shigar da fayil ɗin CSV da ke samuwa a cikin ma’ajiyar gajimare, ‘outputFile’ tare da sunan sakamakon HTML fayil da za a ƙirƙira a cikin ma’ajiyar gajimare da ‘accessToken’ tare da alamar samun damar JWT da aka samar a sama.
Kammalawa
A ƙarshe, tafiya daga CSV zuwa HTML ta buɗe hanyoyi guda biyu daban-daban amma masu tasiri. NET Cloud SDK yana ba da ayyuka masu alaƙa da Excel iri-iri, yana aiki azaman kayan aiki mai ƙarfi don sarrafa bayanan CSV kuma yana tsara jujjuyawar sa zuwa tsari iri-iri, yana shimfida tushe don ingantaccen canji na bayanai. A gefe guda, umarnin cURL tare da Aspose.Cells Cloud API yana ba da tsari mai sauƙi, tushen tushen girgije, sauƙaƙe tsarin juzu’i da tabbatar da isar da abun ciki na HTML mai ƙarfi. Yanzu ya danganta da buƙatun ku, haɗa waɗannan mafita kuma haɓaka gabatarwar bayanai akan gidan yanar gizo. Don haka, shiga cikin sabon zamani na mu’amala da abun ciki mai jan hankali na gani!
Hanyoyin haɗi masu amfani
Labarai masu alaka
Muna ba da shawarar ziyartar shafukan yanar gizo masu zuwa: