yafi json

Maida Excel zuwa JSON ta amfani da C# .NET

A cikin duniyar kasuwanci ta yau mai sauri, ingantaccen sarrafa bayanai shine mabuɗin ci gaba da gasar. Don haka, bayanan sun zama kayayyaki mai mahimmanci kuma ingantaccen sarrafa shi yana da mahimmanci ga ƙungiyoyi masu girma dabam. Wani muhimmin al’amari na sarrafa bayanai shine canza bayanai, wanda ya haɗa da canza bayanai daga wannan tsari zuwa wani don sa ya zama mai amfani da sauƙi. Tare da karuwar buƙatun musayar bayanai, ya zama wajibi ga masu haɓakawa don samun ingantaccen ingantaccen bayani wanda zai iya ɗaukar ayyuka masu yawa na juyawa. Wannan shafin yanar gizon fasaha zai gabatar da mafita mai yanke hukunci don Excel zuwa JSON juyawa kuma ya bayyana fasalulluka, fa’idodi, da iyawar sa, yana ba da cikakken bayyani na wannan mafita da aikace-aikacen sa.

Gabatarwa zuwa Excel zuwa JSON Canjin API

Ɗaya daga cikin muhimman al’amurran sarrafa bayanai shine canza bayanai daga wannan tsari zuwa wani, kuma wannan shine inda Aspose.Cells Cloud SDK don NET ya shigo. Tare da siffofi masu ƙarfi da sassauƙa, wannan API na tushen girgije yana ba da sauƙi da sauƙi. ingantaccen bayani don canza maƙunsar bayanai na Excel zuwa tsarin JSON. Ko kai mai haɓaka software ne da ke neman sarrafa ayyukan canza bayanan ku, ko kuma mai amfani da kasuwanci yana buƙatar sauya maƙunsar bayanai don amfani a cikin aikace-aikacen yanar gizo ko wayar hannu, Aspose.Cells Cloud SDK na NET yana ba da ingantaccen kuma dacewa. mafita. Za mu ƙara bincika iyawar API ɗin, kuma za mu nuna matakan yin juzu’in Excel zuwa JSON cikin sauƙi.

Domin amfani da SDK, muna buƙatar ƙara bayanin sa azaman kunshin NuGet. Bincika “Aspose.Cells-Cloud” a cikin mai sarrafa fakitin NuGet kuma ƙara fakitin.

Aspose.Cells Cloud

Hoto 1:- Aspose.Cells Cloud NuGet kunshin.

Bugu da ƙari, muna kuma buƙatar samun asusun dashboard ɗin Cloud. Idan ba ku da asusun da ke akwai, da fatan za a ƙirƙiri asusun kyauta akan Cloud Dashboard ta amfani da ingantaccen adireshin imel kuma sami keɓaɓɓen bayanan abokin ciniki.

Excel zuwa JSON ta amfani da C#

Wannan sashe yana bayanin duk cikakkun bayanai masu mahimmanci kan yadda ake canza Excel zuwa JSON ta amfani da snippet code C#. Lura, wannan misalin yana amfani da input.xls takardar aiki.

yafi json

Hoto na 2: - Samfotin juyawa na Excel zuwa JSON.

// 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 ta hanyar samar da ClientID da bayanan sirri na ClientSecret
CellsApi instance = new CellsApi(clientID, clientSecret);

// Sunan shigar da fayil na Excel
string name = "input.xls";
// Tsarin fayil ɗin sakamako
string format = "JSON";

// sunan resultant fayil
string resultantFile = "Converted.json";
        
try
{
    // loda fayil ɗin daga rumbun gida
    using (var file = System.IO.File.OpenRead(name))
    {

        // fara aikin juyawa
        var response = instance.CellsWorkbookPutConvertWorkbook(file, format: format, outPath: resultantFile);
                
        // buga saƙon nasara idan tuba ya yi nasara
        if (response != null && response.Equals("OK"))
        {
            Console.WriteLine("Excel to JSON successfully converted !");
            Console.ReadKey();
        }
    }
catch (Exception ex)
{
    Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}

Yanzu bari mu yi ƙoƙarin fahimtar snippet code na sama:

CellsApi instance = new CellsApi(clientID, clientSecret);

Ƙirƙiri misali na CellsApi yayin ƙaddamar da shaidar abokin ciniki azaman muhawara.

var file = System.IO.File.OpenRead(name)

Karanta shigarwar takardar aikin Excel ta amfani da hanyar OpenRead(…) na tsarin System.IO.File.

instance.CellsWorkbookPutConvertWorkbook(file, format: format, outPath: resultantFile);  

Kira hanyar don yin jujjuyawar Excel zuwa JSON kuma adana fitarwa a cikin ma’ajin gajimare.

XLS zuwa JSON ta amfani da Umarnin CURL

Mun fahimci cewa cURL kayan aikin layin umarni ne don samun damar APIs REST, yana mai da shi kayan aiki mai mahimmanci ga masu haɓakawa da ƙwararrun IT. Tare da cURL, za mu iya yin buƙatun HTTP zuwa REST APIs, dawo da bayanai daga sabobin, da aiwatar da ayyuka daban-daban. Yanzu a cikin wannan sashe, za mu canza XLS zuwa JSON ta amfani da umarnin CURL.

Yanzu, a matsayin abin da ake buƙata, muna buƙatar fara samar da alamar samun damar JWT (bisa ga shaidar abokin ciniki) ta amfani 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"

Umurni mai zuwa yana tsammanin shigar da XLS ya kasance a cikin ma’ajin gajimare kuma bayan jujjuya, za mu adana shi akan tuƙi na gida.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/output.xls?format=JSON&isAutoFit=false&onlySaveTable=false&checkExcelRestriction=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>
-o "Converted.json"

Idan muna buƙatar loda shigarwar XLS daga Cloud Cloud kuma bayan tuba zuwa JSON, muna buƙatar adana fitarwa kai tsaye a cikin ma’ajin girgije ɗaya, sannan da fatan za a gwada amfani da umarnin mai zuwa.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/output.xls?format=JSON&isAutoFit=false&onlySaveTable=false&outPath=converted.json&checkExcelRestriction=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>

Tukwici mai sauri

Neman Excel zuwa JSON Converter kyauta! Da fatan za a gwada amfani da kan layi Excel Converter.

Karshen Magana

A ƙarshe, Aspose.Cells Cloud SDK don NET shine mafita mai ƙarfi da sassauƙa don canza maƙunsar bayanai na Excel zuwa tsarin JSON. Tare da tsarin gine-ginen girgijen sa, mai sauƙin amfani mai amfani, da abubuwan ci-gaba, wannan API ɗin yana samar da ingantacciyar hanya don aiwatar da ayyukan sauya bayanai, ko da kuwa kai mai haɓaka software ne ko mai amfani da kasuwanci. Ko kuna buƙatar canza maƙunsar rubutu guda ɗaya ko maƙunsar bayanai da yawa a lokaci ɗaya, Aspose.Cells Cloud SDK don NET yana ba da ingantaccen ingantaccen bayani. Ta amfani da wannan API ɗin, zaku iya daidaita ayyukan canza bayanan ku, adana lokaci da albarkatu, da kuma mai da hankali kan ƙarin mahimman abubuwan kasuwancin ku.

Muna ba da shawarar sosai bincika Takardun Samfura, wanda ya ƙunshi ɗimbin tarin batutuwan da ke bayanin wasu abubuwan ban sha’awa na API. A ƙarshe, idan kun ci karo da kowace matsala yayin amfani da API, ko kuna da wata tambaya mai alaƙa, da fatan za ku ji daɗin tuntuɓar mu ta hanyar Taron Tallafi na Samfura.

Labarai masu alaka

Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: