Array to Excel avatar
Array to Excel

Pricing

Pay per usage

Go to Store
Array to Excel

Array to Excel

Developed by

Hamza Alwan

Hamza Alwan

Maintained by Community

Converts any array of objects to Excel

0.0 (0)

Pricing

Pay per usage

1

Total users

7

Monthly users

2

Runs succeeded

>99%

Last modified

2 years ago

.actor/Dockerfile

# Specify the base Docker image. You can read more about
# the available images at https://docs.apify.com/sdk/js/docs/guides/docker-images
# You can also use any other image from Docker Hub.
FROM apify/actor-node:16 AS builder
# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
COPY package*.json ./
# Install all dependencies. Don't audit to speed up the installation.
RUN npm install --include=dev --audit=false
# Next, copy the source files using the user set
# in the base image.
COPY . ./
# Install all dependencies and build the project.
# Don't audit to speed up the installation.
RUN npm run build
# Create final image
FROM apify/actor-node:16
# Copy just package.json and package-lock.json
# to speed up the build using Docker layer cache.
COPY package*.json ./
# Install NPM packages, skip optional and development dependencies to
# keep the image small. Avoid logging too much and print the dependency
# tree for debugging
RUN npm --quiet set progress=false \
&& npm install --omit=dev --omit=optional \
&& echo "Installed NPM packages:" \
&& (npm list --omit=dev --all || true) \
&& echo "Node.js version:" \
&& node --version \
&& echo "NPM version:" \
&& npm --version \
&& rm -r ~/.npm
# Copy built JS files from builder image
COPY --from=builder /usr/src/app/dist ./dist
# Next, copy the remaining files and directories with the source code.
# Since we do this after NPM install, quick build will be really fast
# for most source file changes.
COPY . ./
# Run the image.
CMD npm run start:prod --silent

.actor/actor.json

{
"actorSpecification": 1,
"name": "getting-started-typescript",
"title": "Getting Started with TypeScript",
"description": "Adds two integers.",
"version": "0.0",
"meta": {
"templateId": "ts-start"
},
"input": "./input_schema.json",
"dockerfile": "./Dockerfile",
"storages": {
"dataset": {
"actorSpecification": 1,
"title": "Converted array results",
"views": {
}
}
}
}

.actor/input_schema.json

{
"title": "Add two integers",
"type": "object",
"schemaVersion": 1,
"properties": {
"array": {
"title": "Source Array for Excel Conversion",
"type": "array",
"description": "",
"editor": "json"
}
},
"required": ["array"]
}

src/main.ts

1// This is the main Node.js source code file of your actor.
2// An actor is a program that takes an input and produces an output.
3
4// For more information, see https://docs.apify.com/sdk/js/
5import { Actor } from 'apify';
6
7interface InputSchema {
8 firstNumber: number;
9 secondNumber: number;
10}
11
12await Actor.init();
13
14console.log('Loading input');
15// Structure of input is defined in .actor/input_schema.json.
16const input = await Actor.getInput<InputSchema>();
17console.log('First number: ', input?.firstNumber);
18console.log('Second number: ', input?.secondNumber);
19
20// 👉 Complete the code so that result is
21// the sum of firstNumber and secondNumber.
22// 👇👇👇👇👇👇👇👇👇👇
23const result = null;
24// 👆👆👆👆👆👆👆👆👆👆
25
26console.log('The result is: ', result);
27
28// Structure of output is defined in .actor/actor.json
29await Actor.pushData({
30 firstNumber: input?.firstNumber,
31 secondNumber: input?.secondNumber,
32 sum: result,
33});
34
35await Actor.exit();

.dockerignore

# configurations
.idea
# crawlee and apify storage folders
apify_storage
crawlee_storage
storage
# installed files
node_modules
# git folder
.git

package.json

{
"name": "getting-started-typescript",
"version": "0.0.1",
"type": "module",
"description": "This is an example of an Apify actor.",
"dependencies": {
"apify": "^3.0.0"
},
"devDependencies": {
"@apify/tsconfig": "^0.1.0",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
},
"scripts": {
"start": "npm run start:dev",
"start:prod": "node dist/main.js",
"start:dev": "ts-node-esm -T src/main.ts",
"build": "tsc",
"test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
},
"author": "It's not you it's me",
"license": "ISC"
}

tsconfig.json

{
"extends": "@apify/tsconfig",
"compilerOptions": {
"module": "ES2022",
"target": "ES2022",
"outDir": "dist",
"noUnusedLocals": false,
"lib": ["DOM"]
},
"include": [
"./src/**/*"
]
}