Excel maƙunsar bayanai kayan aiki ne masu mahimmanci don adanawa, sarrafawa da nazarin bayanai. Koyaya, ana iya samun lokutan da kuke buƙatar canza bayanan ku na Excel zuwa wani tsari, kamar CSV, don sa ya fi dacewa ga wasu ko shigo da shi cikin wani aikace-aikacen. Labari mai dadi shine cewa canza Excel zuwa CSV bai taɓa yin sauƙi ba, amma godiya ga Aspose.Cells Cloud. API ne mai ƙarfi na tushen girgije wanda ke ba da ikon canza bayanan Excel zuwa tsarin fayil iri-iri, gami da CSV, tare da ƴan layukan lamba. A cikin wannan labarin, za mu nuna muku yadda ake amfani da Aspose.Cells Cloud don canza maƙunsar bayanai na Excel zuwa tsarin CSV, da kuma bincika fa’idodin amfani da wannan API mai ƙarfi don buƙatun canza bayanan ku.
- API ɗin Canjin Excel zuwa CSV
- Canza Excel zuwa CSV ta amfani da C#
- XLSX zuwa CSV ta amfani da Umarnin CURL
API ɗin Canjin Excel zuwa CSV
Koyi yadda ake sauƙaƙa tsarin sauya bayanan Excel zuwa tsarin CSV tare da taimakon Aspose.Cells Cloud. Wannan API yana goyan bayan sabbin nau’ikan Excel kuma yana ba da cikakkiyar tsarin fasali waɗanda ke sauƙaƙa sauya bayanai tsakanin tsarin fayil daban-daban. Hakazalika, Aspose.Cells Cloud SDK for .NET yana ba da hanya mai sauƙi kuma madaidaiciya don canza Excel zuwa CSV ta amfani da yaren shirye-shiryen C# (ta amfani da layukan lamba). Don haka, ko kai mafari ne ko ƙwararren mai haɓakawa, wannan labarin zai taimake ka ka fara da Excel zuwa CSV ta amfani da Aspose.Cells Cloud SDK don NET.
Don farawa da amfani da SDK, muna buƙatar ƙara bayanin sa ta mai sarrafa fakitin NuGet. Kawai bincika “Aspose.Cells-Cloud” kuma danna maɓallin Ƙara Kunshin.
Yanzu, don amfani da damar API, muna kuma buƙatar samun asusun dashboard na Cloud. Idan ba a riga an yi rajista ba, 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.
Canza Excel zuwa CSV ta amfani da C#
An ba da ƙasa shine snippet na lambar wanda zai iya taimaka mana mu canza Excel zuwa CSV ba tare da amfani da Microsoft Office Automation ba ko wani kayan aiki da aka shigar. Kamar yadda zaku iya lura, duk tsari yana da sauƙi kuma madaidaiciya gaba.
// 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 fayil ɗin shigarwar mu na Excel
string name = "TestCase.xls";
// Tsarin fayil ɗin sakamako
string format = "CSV";
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: null);
// Ajiye sakamakon CSV zuwa faifan gida
using (var fileStream = new FileStream("myResultant.csv", System.IO.FileMode.OpenOrCreate, FileAccess.Write))
{
response.CopyTo(fileStream);
}
// buga saƙon nasara idan tuba ya yi nasara
if (response != null && response.Equals("OK"))
{
Console.WriteLine("Excel to CSV successfully converted !");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Bari mu fahimci snippet code na sama:
CellsApi instance = new CellsApi(clientID, clientSecret);
Ƙirƙiri wani abu na CellsApi inda muka wuce bayanan 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.
CellsWorkbookPutConvertWorkbook(file, format: format, outPath: resultantFile);
Wannan hanyar tana haifar da aikin juyawa na Excel zuwa CSV kuma yana adana sakamakon CSV a cikin ma’ajiyar girgije.
using (var fileStream = new FileStream("myResultant.csv", System.IO.FileMode.OpenOrCreate, FileAccess.Write))
{
response.CopyTo(fileStream);
}
Yi amfani da wannan lambar don adana sakamakon CSV zuwa faifan gida
Yi amfani da hanyar haɗin da ke biyowa don zazzage samfurin aikin Excel TestCase.xlsx da aka yi amfani da shi a ciki misalin da ke sama.
XLSX zuwa CSV ta amfani da Umarnin CURL
Akwai dalilai da yawa da ya sa samun damar Aspose.Cells Cloud ta umarnin cURL babban zaɓi ne ga masu haɓakawa. Wasu fa’idodin amfani da umarnin cURL sun haɗa da:
- Automation: Aiwatar da tsarin jujjuyawa ta atomatik, yana sauƙaƙa shi kuma mafi inganci.
- Daidaita-dandamali: Ana goyan bayan Windows, macOS, da Linux, yana mai da shi zaɓi mai kyau ga masu haɓaka aiki tare da nau’ikan tsarin aiki.
- Sauƙi don haɗawa: Haɗa tare da wasu kayan aiki da tsarin (haɗa cikin ayyukan aiki na yanzu).
- Sassauci: Ba ka damar tantance tsari da tsarin fitarwa.
- Ingantattun tsaro: za ka iya tabbatar da cewa mahimman bayanai sun kasance amintacce, saboda tsarin bai ƙunshi aika bayanai zuwa gidan yanar gizo ko aikace-aikace na ɓangare na uku ba.
Yanzu, mataki na farko a cikin tsarin juyawa shine samar da alamar samun damar JWT dangane da shaidar abokin cinikinmu:
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"
Bayan tsarar alama, da fatan za a aiwatar da umarni mai zuwa don canza XLSX zuwa CSV kuma adana fitarwa zuwa ma’ajiyar girgije:
curl -v -X GET "https://api.aspose.cloud/v3.0/cells/TestCase(1).xlsx?format=CSV&isAutoFit=false&onlySaveTable=false&outPath=output.csv&checkExcelRestriction=true" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
Idan muna sha’awar adana CSV da aka fitar zuwa cikin gida, da fatan za a gwada amfani da umarnin cURL mai zuwa:
curl -v -X GET "https://api.aspose.cloud/v3.0/cells/TestCase(1).xlsx?format=CSV&isAutoFit=false&onlySaveTable=false&checkExcelRestriction=true" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-o "output.csv"
Karshen Magana
A ƙarshen wannan labarin, mun kammala cewa Aspose.Cells Cloud yana ba da hanya mai dacewa kuma amintacce don canza maƙunsar bayanan Excel zuwa tsarin CSV ta amfani da harshen shirye-shirye na C#. Bugu da ƙari kuma, wannan API yana ba da fasali da ayyuka masu yawa, yana mai da shi mafita mai kyau ga masu haɓakawa da kasuwancin da ke buƙatar canza bayanan Excel zuwa tsarin CSV. Ko kuna neman sarrafa tsarin tsarin bayanan ku, ko kuma kawai kuna son yin tsarin jujjuyawa cikin sauƙi da inganci, Aspose.Cells Cloud shine cikakken bayani a gare ku. Tare da haɗin gwiwar mai amfani da shi, cikakkun fasalulluka, da ingantaccen SDK don NET, za ku iya tabbata cewa kuna samun mafi kyawun mafita don buƙatun canza bayanan ku. Don haka, idan kuna neman hanya mai sauri da inganci don canza Excel zuwa CSV, gwada amfani da Aspose.Cells Cloud a yau.
Da fatan za a daina bincika Takardun Samfura, wanda ya ƙunshi batutuwa masu ban mamaki waɗanda ke bayanin duk abubuwan ban sha’awa na API. A ƙarshe, idan kun ci karo da wasu batutuwa yayin amfani da API, da fatan za ku ji daɗin tuntuɓar mu ta hanyar [Zauren Tallafin Samfura] kyauta 9.
Labarai masu alaka
Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: