Excel to text

Excel (XLS, XLSX) 파일을 Node.js로 텍스트로 변환하기

대량의 데이터셋이나 텍스트 전용 출력물을 처리할 때, Excel 파일을 텍스트 (.txt)로 변환하는 것이 데이터 처리를 단순화하는 데 중요합니다. 텍스트 파일은 가벼우며, 플랫폼에 구애받지 않고, 소프트웨어 및 자동화 파이프라인에서 작업하기 쉽습니다.

이 기사에서는 Aspose.Cells Cloud SDK를 사용하여 Node.js에서 Excel을 텍스트로 변환하는 방법을 배우게 됩니다. 이는 빠르고, 확장 가능하며, 개발자 친화적인 API를 제공합니다.

🚀 Node.js API for Excel to Text Conversion

Aspose.Cells Cloud for Node.js 를 사용하면 데이터 구조를 손실하지 않고 Excel 파일을 깔끔한 텍스트 출력으로 쉽게 변환할 수 있습니다. SDK는 XLS, XLSX, XLSM 등 많은 형식을 지원합니다.

✅ 주요 이점:

  • 최소한의 코딩으로 빠른 변환.
  • 대용량 Excel 파일을 지원합니다.
  • Node.js 앱과의 쉬운 통합.

SDK를 npm을 통해 설치하십시오:

npm install asposecellscloud --save

Make sure you have your Client ID and Client Secret ready from the Aspose Cloud Dashboard.

📄 Node.js를 사용하여 Excel을 텍스트로 변환하기

Excel을 TXT 형식으로 변환하기 위해 RESTful API를 사용하는 방법으로는 다음 중 하나를 고려할 수 있습니다.

GetWorkbook - 클라우드 저장소에서 입력 Excel을 가져오고 출력 결과를 클라우드 저장소에 저장합니다. PutConvertWorkbook - 요청 내용에서 Excel 파일을 다른 형식으로 변환합니다. PostWorkbookSaveAs - 엑셀 파일을 다른 형식으로 저장소에 저장합니다.

다음 단계를 따르십시오. Excel 스프레드시트를 .txt 파일로 단계별로 변환하는 방법:

우선, 클라이언트 ID와 클라이언트 비밀 정보를 인수로 받는 CellsApi 클래스의 객체를 생성하십시오. createReadStream(…) 메서드를 사용하여 입력 XLS 파일을 읽고, 그런 다음 uploadFile(…) 메서드를 사용하여 파일을 클라우드 스토리지에 업로드합니다. CellsSaveAsPostDocumentSaveAsRequest(…) 클래스의 객체를 생성한 다음 cellsSaveAsPostDocumentSaveAs(..) 메서드를 호출하여 변환 프로세스를 시작합니다.

const { CellsApi, CellsSaveAs_PostDocumentSaveAsRequest,UploadFileRequest,PdfSaveOptions } = require("asposecellscloud");

// Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).
const clientId = "718e4235-8866-4ebe-bff4-f5a14a4b6466";
const clientSecret = "388e864b819d8b067a8b1cb625a2ea8e";

// CellsApi의 인스턴스를 생성하십시오.
const cellsApi = new CellsApi(clientId, clientSecret);

// name of input Excel document
filename = "source.xlsx"

// 코드에 파일 시스템 모듈 참조를 포함하세요.
const fs = require("fs");

// 입력 Excel 파일의 내용을 읽습니다.
var data =fs.createReadStream("/Users/nayyershahbaz/Downloads/"+ filename);

// FileUpload 요청 인스턴스 생성
var req = new UploadFileRequest();
req.path = filename;
// 로드된 Excel 파일을 포함하는 Stream 인스턴스로 콘텐츠 설정
req.file = data;

// 파일을 클라우드 스토리지에 업로드하세요.
return cellsApi.uploadFile(req)
    .then((result) => {
        // Document SaveAsRequest 인스턴스 생성
        var req = new CellsSaveAs_PostDocumentSaveAsRequest();
        req.name = filename;

        // PdfSaveOptions 클래스의 객체를 생성합니다.
        req.saveOptions = new PdfSaveOptions();
  
        // 결과 파일 형식을 텍스트 파일로 설정합니다.
        req.saveOptions.saveFormat = "txt";
        
        // 새로 생성된 파일의 이름을 설정하세요.
        req.newfilename = "resultant.txt";
        // since we are going to save in default location, so we will set null as folder value        
        req.folder = null;
    
        // SaveAsPostDocument 메서드를 호출하여 변환 프로세스를 시작하세요.     
        return cellsApi.cellsSaveAsPostDocumentSaveAs(req)
            .then((result) => {
            expect(result.body.code).to.equal(200);
            expect(result.response.statusCode).to.equal(200);
        });
    });

입력 Excel 워크북 input.xls와 결과물 output.txt를 테스트 목적으로 다운로드해 주세요.

💻 Excel to Text Conversion via cURL Command

명령어 도구를 선호하나요? cURL 명령어를 사용하여 변환을 수행할 수도 있습니다.

✅ cURL 접근 방식의 장점:

SDK 설치가 필요하지 않습니다. 빠른 자동화 스크립트에 적합합니다. 데이터 보안과 효율성이 향상되었습니다.

Step 1: OAuth 액세스 토큰을 생성합니다:

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

2단계: PostWorkbookSaveAs 메서드를 실행하여 Excel을 텍스트 파일로 변환합니다:

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\"}"

🛠️ 무료 Excel to Text 변환기 온라인 이용해 보세요

You can also try our free online Excel to TXT converter App for instant results without any coding.

excel to text file

Excel to TEXT File conversion App.

🔗 유용한 자원

✅ 결론

Using Aspose.Cells Cloud SDK for Node.js, you can easily convert Excel files to Text (.txt), making data lighter, easier to manage, and more accessible across different platforms.

아스포즈는 Node.js SDK를 앱에 통합하든 자동화를 위해 cURL을 사용하든 관계없이 파일 형식 변환을 위한 신뢰할 수 있고, 확장 가능하며, 개발자 친화적인 솔루션을 제공합니다.

오늘 Node.js Excel to Text API의 강력한 기능으로 Excel 데이터를 변환하기 시작하세요!

📚 추천 기사

다음 링크를 방문하여 더 많은 정보를 확인하십시오: