Array to Excel
Try for free
No credit card required
View all Actors
Array to Excel
hamza.alwan/array-to-excel
Try for free
No credit card required
Converts any array of objects to Excel
.actor/Dockerfile
1# Specify the base Docker image. You can read more about
2# the available images at https://docs.apify.com/sdk/js/docs/guides/docker-images
3# You can also use any other image from Docker Hub.
4FROM apify/actor-node:16 AS builder
5
6# Copy just package.json and package-lock.json
7# to speed up the build using Docker layer cache.
8COPY package*.json ./
9
10# Install all dependencies. Don't audit to speed up the installation.
11RUN npm install --include=dev --audit=false
12
13# Next, copy the source files using the user set
14# in the base image.
15COPY . ./
16
17# Install all dependencies and build the project.
18# Don't audit to speed up the installation.
19RUN npm run build
20
21# Create final image
22FROM apify/actor-node:16
23
24# Copy just package.json and package-lock.json
25# to speed up the build using Docker layer cache.
26COPY package*.json ./
27
28# Install NPM packages, skip optional and development dependencies to
29# keep the image small. Avoid logging too much and print the dependency
30# tree for debugging
31RUN npm --quiet set progress=false \
32 && npm install --omit=dev --omit=optional \
33 && echo "Installed NPM packages:" \
34 && (npm list --omit=dev --all || true) \
35 && echo "Node.js version:" \
36 && node --version \
37 && echo "NPM version:" \
38 && npm --version \
39 && rm -r ~/.npm
40
41# Copy built JS files from builder image
42COPY /usr/src/app/dist ./dist
43
44# Next, copy the remaining files and directories with the source code.
45# Since we do this after NPM install, quick build will be really fast
46# for most source file changes.
47COPY . ./
48
49
50# Run the image.
51CMD npm run start:prod --silent
.actor/actor.json
1{
2 "actorSpecification": 1,
3 "name": "getting-started-typescript",
4 "title": "Getting Started with TypeScript",
5 "description": "Adds two integers.",
6 "version": "0.0",
7 "meta": {
8 "templateId": "ts-start"
9 },
10 "input": "./input_schema.json",
11 "dockerfile": "./Dockerfile",
12 "storages": {
13 "dataset": {
14 "actorSpecification": 1,
15 "title": "Converted array results",
16 "views": {
17 }
18 }
19 }
20}
.actor/input_schema.json
1{
2 "title": "Add two integers",
3 "type": "object",
4 "schemaVersion": 1,
5 "properties": {
6 "array": {
7 "title": "Source Array for Excel Conversion",
8 "type": "array",
9 "description": "",
10 "editor": "json"
11 }
12 },
13 "required": ["array"]
14}
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
1# configurations
2.idea
3
4# crawlee and apify storage folders
5apify_storage
6crawlee_storage
7storage
8
9# installed files
10node_modules
11
12# git folder
13.git
package.json
1{
2 "name": "getting-started-typescript",
3 "version": "0.0.1",
4 "type": "module",
5 "description": "This is an example of an Apify actor.",
6 "dependencies": {
7 "apify": "^3.0.0"
8 },
9 "devDependencies": {
10 "@apify/tsconfig": "^0.1.0",
11 "ts-node": "^10.9.1",
12 "typescript": "^4.9.5"
13 },
14 "scripts": {
15 "start": "npm run start:dev",
16 "start:prod": "node dist/main.js",
17 "start:dev": "ts-node-esm -T src/main.ts",
18 "build": "tsc",
19 "test": "echo \"Error: oops, the actor has no tests yet, sad!\" && exit 1"
20 },
21 "author": "It's not you it's me",
22 "license": "ISC"
23}
tsconfig.json
1{
2 "extends": "@apify/tsconfig",
3 "compilerOptions": {
4 "module": "ES2022",
5 "target": "ES2022",
6 "outDir": "dist",
7 "noUnusedLocals": false,
8 "lib": ["DOM"]
9 },
10 "include": [
11 "./src/**/*"
12 ]
13}
Developer
Maintained by Community
Actor metrics
- 1 monthly user
- 1 star
- 100.0% runs succeeded
- Created in May 2023
- Modified about 1 year ago
Categories