- Features of XLS/XLSX to TXT API Endpoint
- Endpoint Parameters to Extract Excel Data
- Step By Step Guide to Convert XLS to TXT
- Convert XLS to TXT – Video Guide
Features of XLS/XLSX to TXT API Endpoint
The PDF.co Web API provides various tools and functionalities which come in handy while working with data extraction and manipulation. The exciting thing about this web API is that it helps preserve the original data structure. For example, when the API converts the XLS file into a TXT format, all table values keep their real places. The API places these values in their exact rows and columns.
The API endpoint has various other features, such as preserving and reproducing the source file’s original layout, allowing conversion to portable and lightweight file formats, supporting multiple languages, and automated platform integration. The users can efficiently convert any excel data file into a text format using this API endpoint.
Another essential feature of PDF.co Web API is the security it provides to consumers. The API supports transmitting all the user documents through encrypted connections. The users can learn more about the PDF.co security protocols here.
Endpoint Parameters to Extract Excel Data
Following are the parameters of the XLS/XLSX to TXT API endpoint:
It is a required parameter and contains a URL to the source file. The users can upload files from various locations such as Dropbox, Google Drive, and built-in storage form PDF.co file storage. The users can also upload files from the API. Moreover, they can encrypt and decrypt the data files using user-controlled data encryption.
It is an optional parameter. It contains HTTP auth user name if it is necessary to access the source URL.
It is an optional parameter. It contains the HTTP auth password if it is compulsory to access the source URL.
It is an optional parameter that must be a string. It contains the name of the output file.
It is an optional parameter representing the output link’s expiration time. The default expiration time is 60 minutes, and after this time, the generated output files will vanish from the temporary storage of PDF.co.
It is an optional parameter containing the worksheet index that users must utilize.
It is an optional parameter which is a boolean. The users can set the parameter as true to return the data as inline or false to return the link to the output file.
It is an optional parameter which is boolean. It helps in running the processes asynchronously. This parameter returns the JobId, allowing users to check the process state. Moreover, the possible process states include working, failed, success, and aborted.
It is an optional parameter that helps set additional configurations for extra options and fine-tuning. This parameter has to be in the string format.
Note: If the users keep getting errors like “ Too many requests” and “ Access Denied” for their input URL, they can try adding “cache:” to enable the built-in URL caching.
The users must provide the necessary variables and parameters to provide the source URL and request the endpoint to generate the TXT format according to the original layout. The code generates the output file, and the users can download it to check and verify the required optimal conversion.
Following is the source file, which contains sample data for testing:
Following is the sample code to convert the XLS data file into a TXT file:
Output of Extracted Excel
The following screenshot is of the output text file. The screenshot explains the structure preservation and verifies the data placements in respective rows and columns:
Step-By-Step Guide to Convert XLS to TXT
Following is the step-by-step guide which explains the working of the above sample code:
- The users need to import all necessary packages for API requests. Here, the “require” parameter represents all the necessary modules. On the other hand, “request” is an essential Node.js module that is required for making an HTTP call. In this scenario, the required package is “path”.
- The next step is to provide the API key to access the PDF.co Web API. There is a limitation to sending the direct request, so the users must provide their specific API key to use it as an access token for the authentication.
- To convert them into text, users must declare and initiate the variables containing the source URL, async process, search string, and regex string. The query path contains relevant API endpoint information. The user has to set the async variable as true to run the process asynchronously for smooth working.
- The next step is to provide API options, including the URL of the API endpoint, the request method, the queryPath, and all the required headers. For this purpose, the users must use the abovementioned “reqOptions” to initialize these variables.
- The final step is to send the POST request to the required API endpoint and verify the API response. If the response status is 200, it represents a successful request, and the code execution provides an output URL for the user. On the other hand, if the response is unsuccessful, the users have to modify and execute the code again to obtain the output file.
Convert XLS to TXT – Video Guide
Below is the Gif representing the execution of the working code: