yafi csv

Canza Excel zuwa CSV a Java

A cikin duniyar da ke sarrafa bayanai na yau, ikon canza fayilolin Excel zuwa CSV (Wakafi-Raba Ƙimar) ya zama mahimmanci. Yayin da ake amfani da fayilolin Excel don adanawa da nazarin bayanai, fayilolin CSV suna ba da tsari mafi sauƙi kuma mafi dacewa wanda za’a iya sarrafa shi cikin sauƙi ta aikace-aikace daban-daban da harsunan shirye-shirye. Canza Excel zuwa CSV yana ba da hanya don daidaita haɗin bayanai, inganta haɗin gwiwa, da sauƙaƙe musayar bayanai tsakanin tsarin daban-daban. A cikin wannan labarin, za mu bincika yadda ake cim ma wannan aikin ta amfani da Java Cloud SDK, yana ba ku ƙarfin jujjuya fayilolin Excel zuwa CSV da buše cikakken damar bayanan ku.

Canza Excel zuwa CSV Cloud SDK

Idan ya zo ga canza fayilolin Excel zuwa CSV ta amfani da Java, Aspose.Cells Cloud SDK don Java ya fito a matsayin mafita mai ƙarfi da inganci. Aspose.Cells Cloud API ne mai fa’ida wanda ke ba da tallafi mai yawa don sarrafa fayil ɗin Excel, gami da ikon canza fayilolin Excel zuwa tsarin CSV ba tare da matsala ba. Don haka, ko kuna aiki akan aikin ƙaura na bayanai, bincike na bayanai, ko duk wani yanayin da ke buƙatar Excel zuwa CSV, Aspose.Cells Cloud SDK yana ba ku ƙarfi tare da kayan aiki da sassauƙa don cimma burin ku da kyau kuma daidai.

Yanzu, da fatan za a ƙara cikakkun bayanai masu zuwa a cikin pom.xml don ƙara bayanin Cloud SDK a cikin aikin ku.

<repositories>
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Java API</name>
        <url>https://repository.aspose.cloud/repo/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-cells-cloud</artifactId>
        <version>22.8</version>
    </dependency>
</dependencies>

Da zarar an ƙara ambaton Cloud SDK, da fatan za a yi rajistar asusu akan Cloud dashboard kuma bincika/ƙirƙiri ID na abokin ciniki da cikakkun bayanan Sirrin Abokin ciniki.

Canza Excel zuwa CSV a Java

Da fatan za a bi umarnin da aka bayar a ƙasa don canza XLSX zuwa tsarin CSV.

  • Ƙirƙiri misali na ajin CellsApi yayin samar da takaddun shaida na abokin ciniki azaman muhawarar shigarwa.
  • Ƙayyade sunan shigar da Excel, tsarin sakamako kamar CSV, da sunan fayil ɗin fitarwa.
  • Loda shigar da littafin aikin Excel zuwa ma’ajiyar gajimare ta amfani da hanyar uploadFile(…).
  • A ƙarshe, kira hanyar cellsWorkbookGetWorkbook(…) don fara aikin jujjuya XLSX zuwa CSV.
// don ƙarin misalai, da fatan za a ziyarci https://github.com/aspose-cells-cloud/aspose-cells-cloud-java

try
    {
    // Samu ClientID da ClientSecret daga https://dashboard.aspose.cloud/
    String clientId = "bbf94a2c-6d7e-4020-b4d2-b9809741374e";
    String clientSecret = "1c9379bb7d701c26cc87e741a29987bb";
  
    // ƙirƙiri misali na CellsApi ta amfani da takaddun shaidar abokin ciniki
    CellsApi api = new CellsApi(clientId,clientSecret);
    		
    // sunan shigar da littafin aikin Excel
    String fileName = "source.xlsx";
    
    // bayanan sirri idan littafin aiki a rufaffen
    String password = null;
    
    // Yana ƙayyade ko saita layuka na littafin aiki don zama autofit.
    Boolean isAutoFit = true;
    // Yana ƙayyade ko ajiye bayanan tebur kawai. Yi amfani da pdf kawai don Excel.
    Boolean onlySaveTable = true;
    // resultant fayil format
    String format = "CSV";
    		
    // loda fayil daga tsarin gida
    File file = new File("c://Users/nayyer/"+fileName);	
    
    // loda shigarwar XLSB zuwa ma'ajin gajimare
    api.uploadFile("input.xlsx", file, "Internal");

    // yi aikin canza takarda
    File response = api.cellsWorkbookGetWorkbook("input.xlsx",  password,format, 
    			            isAutoFit, onlySaveTable, null,"Internal",  "Resultant.csv","Internal", null);        
            
    // buga sakon nasara
    System.out.println("Excel to CSV sucessfully converted !");
    }catch(Exception ex)
    {
        System.out.println(ex);
    }
excel zuwa csv fayil preview

image1: - Excel zuwa CSV preview fayil

Za a iya sauke samfurin fayilolin da aka yi amfani da su a cikin misalin da ke sama daga myDocument.xlsx da Resultant.csv.

Maida XLSX na gida zuwa CSV

A cikin wannan sashe, za mu koyi matakai kan yadda ake canza XLSX zuwa CSV ba tare da loda fayil ɗin shigarwa zuwa ma’ajiyar girgije ba. Don haka da fatan za a bi umarnin da aka bayar a ƙasa.

  • Ƙirƙiri misali na CellsApi yayin samar da takaddun shaida na abokin ciniki azaman muhawarar shigarwa.
  • Ƙayyade sunan shigar da Excel, tsarin sakamako azaman CSV, da sunan fayil ɗin fitarwa.
  • Na uku, kira hanyar cellsWorkbookPutConvertWorkbook(…) don fara jujjuyawar XLSX zuwa CSV.
// don ƙarin misalai, da fatan za a ziyarci https://github.com/aspose-cells-cloud/aspose-cells-cloud-java

try
    {
    // Samu ClientID da ClientSecret daga https://dashboard.aspose.cloud/
    String clientId = "bbf94a2c-6d7e-4020-b4d2-b9809741374e";
    String clientSecret = "1c9379bb7d701c26cc87e741a29987bb";

    // ƙirƙiri misali na CellsApi ta amfani da takaddun shaidar abokin ciniki
    CellsApi api = new CellsApi(clientId,clientSecret);
    		
    // sunan shigar da littafin aiki na XLSX
    String fileName = "myDocument.xlsx";
    // bayanan sirri idan littafin aiki a rufaffen
    String password = null;
    // resultant fayil format
    String format = "CSV";
    		
    // loda fayil daga tsarin gida
    File file = new File("c://Users/nayyer/"+fileName);	
    
    // Maida XLSX zuwa CSV aiki
    File response = api.cellsWorkbookPutConvertWorkbook(file, format, password, "Converted.csv", null, null);  
            
    // buga sakon nasara
    System.out.println("Excel to CSV sucessfully converted !");
    }catch(Exception ex)
    {
        System.out.println(ex);
    }

XLSX zuwa CSV ta amfani da Umarnin CURL

Wata hanya mai ƙarfi don sauya fayilolin Excel zuwa CSV ita ce ta umarnin cURL da Aspose.Cells Cloud REST API. Tare da Aspose.Cells Cloud REST API, zaku iya yin ayyuka daban-daban akan fayilolin Excel, gami da juyawa zuwa CSV, ta amfani da umarnin cURL masu sauƙi da madaidaiciya. Ta hanyar yin amfani da ikon umarnin cURL da Aspose.Cells Cloud REST API, za ku iya sarrafa tsarin jujjuyawa, sarrafa manyan fayilolin Excel, da kuma cimma sakamako mai inganci kuma abin dogara.

Yanzu, aiwatar da umarni mai zuwa don samar da alamar shiga JWT:

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Da zarar an ƙirƙiri JWT, da fatan za a aiwatar da umarni mai zuwa don canza XLSX zuwa CSV kuma adana fitarwa a cikin ma’ajin gajimare. Lura cewa shigar da XLSX ya riga ya kasance a cikin ma’ajin gajimare.

curl -v -X GET "https://api.aspose.cloud/v3.0/cells/myDocument(1).xlsx?format=CSV&isAutoFit=false&onlySaveTable=false&outPath=converted.csv&checkExcelRestriction=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Kammalawa

Ko ka zaɓa don amfani da Aspose.Cells Cloud SDK don Java ko yin amfani da umarnin cURL tare da Aspose.Cells Cloud REST API, kuna da kayan aiki masu ƙarfi a wurin ku don juyawa Excel zuwa CSV. Waɗannan hanyoyin suna ba da sassauci, haɓakawa, da sauƙi na haɗin kai, ba ku damar canza fayilolin Excel zuwa tsarin CSV ba tare da wahala ba. Don haka, ta hanyar yin amfani da waɗannan fasahohin, zaku iya sarrafa tsarin jujjuyawa, daidaita ayyukanku, da fitar da bayanai masu mahimmanci daga fayilolin Excel a cikin tsarin da ya dace da sauƙin shiga.

Hanyoyin haɗi

Labarai masu alaka

Muna ba da shawarar ziyartar hanyoyin haɗin yanar gizo masu zuwa don ƙarin koyo game da: