Excel maƙunsar bayanai kayan aiki ne na ko’ina don sarrafa da nazarin bayanai. Duk da haka, ba koyaushe ba ne mafi kyawun tsari don aikace-aikacen yanar gizo. Don haka, canza fayilolin Excel zuwa fayil ɗin rubutu (.txt) aiki ne na gama gari a sarrafa bayanai, saboda yana bawa masu amfani damar sarrafa bayanai cikin ƙari. m da kuma iya karanta format. Fayilolin rubutu kuma suna da nauyi kuma suna da sauƙin buɗewa a cikin shirye-shirye daban-daban, yana mai da su kyakkyawan zaɓi don adanawa da raba bayanai. Koyaya, canza fayilolin Excel zuwa tsarin rubutu (.txt) na iya zama ɗawainiya mai ban tsoro, musamman idan ba ku saba da yarukan shirye-shirye ba. Abin farin ciki, tare da C# .NET, kuna iya canza fayilolin Excel ɗinku cikin sauƙi zuwa tsarin rubutu ba tare da ƙoƙari sosai ba. A cikin wannan jagorar, za mu nuna muku yadda ake canza bayanan Excel ɗinku zuwa fayil ɗin rubutu (.txt) ta amfani da NET Cloud SDK.
- API ɗin Canjin rubutu zuwa Excel
- Maida Excel zuwa TXT ta amfani da C#
- Excel zuwa Fayil Rubutu ta amfani da Umarnin CURL
API ɗin Canjin rubutu zuwa Excel
Aspose.Cells Cloud SDK don NET hanya ce mai inganci kuma mai tsada don sauya fayilolin Excel zuwa tsarin rubutu (.txt). Wannan tsarin tushen gajimare yana ba da fa’idodi masu yawa, gami da haɓakawa, samun dama, da ingantattun fasalulluka na tsaro. Tsarin juyawa shine abin dogaro, kuma yana haifar da sakamako mai inganci. Kawai bincika “Aspose.Cells-Cloud” kuma danna maɓallin Ƙara Kunshin. Na biyu, idan baku da asusu akan Cloud Dashboard, da fatan za a ƙirƙiri asusun kyauta ta amfani da ingantaccen adireshin imel kuma sami keɓaɓɓen takaddun shaidarku.
Maida Excel zuwa TXT ta amfani da C#
API ɗin yana ba da hanyoyi guda uku masu zuwa don magance canjin tsarin fayil.
GetWorkbook - Sami shigar da Excel daga ma’ajin gajimare & adana fitarwa zuwa ma’ajiyar girgije. PutConvertWorkbook - Yana canza fayil ɗin Excel zuwa wasu tsari daga buƙatar abun ciki. PostWorkbookSaveAs - Ajiye fayil ɗin Excel azaman fayil ɗin sauran tsarin zuwa ajiya.
Yanzu a cikin wannan sashe, sha’awarmu ita ce shigar da fayil ɗin Excel daga faifan gida, aiwatar da juyawa da adana sakamakon rubutu a cikin ma’ajiyar girgije.
// 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);
// Littafin aikin farko na Excle akan tuƙi
string input_Excel = "input.xlsx";
// sunan sakamakon Rubutun fayil
string resultant_File = "output.txt";
try
{
// karanta fayil ɗin Excel a cikin misalin Fayil
var file = System.IO.File.OpenRead(input_Excel);
// fara aikin juyawa
var response = cellsInstance.CellsWorkbookPutConvertWorkbook(file, format:"TXT", outPath:resultant_File);
// buga saƙon nasara idan haɗin kai ya yi nasara
if (response != null && response.Equals("OK"))
{
Console.WriteLine("Excel to Text converted successfully !");
Console.ReadKey();
}
}
catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
Bari mu haɓaka fahimtarmu game da wannan snippet code:
CellsApi cellsInstance = new CellsApi(clientID, clientSecret);
Ƙirƙiri wani abu na CellsApi yayin ƙaddamar da bayanan abokin ciniki azaman muhawara.
var file = System.IO.File.OpenRead(input_Excel);
Karanta abun ciki na shigar da littafin aikin Excel cikin abu FileStream.
var response = cellsInstance.CellsWorkbookPutConvertWorkbook(file, format:"TXT", outPath:resultant_File);
Kira API don canza Excel zuwa Tsarin Rubutu. Tsarin fayil na sakamakon da sakamakon sunan fayil ɗin rubutu, an bayar da shi azaman hujja ga wannan hanyar. Bayan jujjuyawar, ana adana fitarwa a cikin ma’ajin gajimare.
Shigar da littafin aikin Excel da sakamakon TXT da aka samar a cikin misalin da ke sama za a iya sauke su daga input.xls da output.txt.
Excel zuwa Fayil Rubutu ta amfani da Umarnin CURL
Mun koyi cewa fayilolin rubutu ba su da nauyi kuma suna da inganci don watsawa ta intanet. Yanzu, a cikin wannan sashe, za mu canza fayilolin Excel zuwa tsarin rubutu ta amfani da Aspose.Cells Cloud REST API da umurnin cURL. Wannan tsarin yana ba da fa’idodi da yawa, kamar dacewa da aikace-aikacen software daban-daban da tsarin aiki, ingantaccen tsaro na bayanai, da haɓaka aiki.
Don haka don farawa, muna buƙatar samar da alamar samun damar JWT dangane da shaidar abokin ciniki:
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"
Mataki na gaba shine a kira API PostWorkbookSaveAs. Wannan API yana ɗaukar shigar da Excel daga ma’ajin gajimare sannan, yana adana sakamakon TXT zuwa ma’ajiyar girgije iri ɗaya.
curl -v -X POST "https://api.aspose.cloud/v3.0/cells/myDocument(2).xlsx/SaveAs?newfilename=converted.txt&isAutoFitRows=false&isAutoFitColumns=false&checkExcelRestriction=true" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"SaveFormat\": \"TXT\"}"
Karshen Magana
A cikin wannan koyawa, mun koyi cewa Aspose.Cells Cloud SDK don NET da umarnin cURL suna ba da hanya mai dacewa da inganci don canza fayilolin Excel zuwa tsarin rubutu. Wannan na iya zama da amfani musamman lokacin aiki tare da manyan bayanan bayanai ko hadaddun dabaru, kamar yadda fayilolin rubutu ke ba masu amfani damar fitar da bayanan da suka dace da sauri ba tare da buƙatar ƙwararrun software ko ƙwarewar shirye-shirye ba.
Duk waɗannan hanyoyin suna ba da fa’idodi masu yawa, gami da dacewa tare da aikace-aikacen software daban-daban da tsarin aiki, ingantaccen tsaro na bayanai, da haɓaka aiki saboda ƙananan girman fayil. Bugu da ƙari, Aspose.Cells Cloud SDK don NET da umarnin cURL suna da sauƙin amfani da ba da sassauci, yana mai da su babban zaɓi ga kasuwanci da daidaikun mutane. Ta hanyar yin amfani da ƙarfin Aspose.Cells Cloud SDK don NET da umarnin cURL, za ku iya canza fayilolin Excel cikin sauri da sauƙi zuwa rubutu, kuma ku sa bayananku su kasance masu sauƙi da aminci. Bari mu fara yau!
Hanyoyin haɗi masu amfani
Abubuwan da aka Shawarar
Da fatan za a ziyarci hanyoyin haɗin yanar gizon don ƙarin koyo game da: