Introduction
In this article, I will explain angular component action and how to read an xlsx file. Please follow the below steps.
Whats is Angular
Angular is a client-side JavaScript framework that allows us to create a Reactive Client-side Application. By design, it comes with a Modular Approach, so you can reuse the code wherever you want. It supports many inbuilt functionalities.
Main of Angular
- Modules
- Components
- Templates
- Metadata
- Data binding
- Directives
- Services
- Dependency Injection
Angular Component Action
- app.component.css
- app.component.html
- app.component.spec.ts
- app.component.ts
- app.module.ts
CSS file
Where we define all the styles for that component. These styles will only be scoped to this component and will not leak to the outside.
HTML file
Contains the markup to render in the DOM.
spec file
Includes the unit tests.
TypeScript file
Where we define the state (the data to display) and behavior (logic) of our component.
- Angular Server serves the index.html and renders the application view in the browser.
- The index.html contains all the JS, styles, compilation files that are required to run the application.
- The index.html holds the root component (AppComponent) which is bootstrapped from the root model and is loaded 1st.
- The index.html should have only one component that is root component by the directive <app-root></app-root> (template directive).
- The selector property value is used to create and attach the instance of the class in the inner HTML of the element.
- A root component with multiple nested child components.
Requirements for the application:
- NodeJs
- Angular CLI
- Visual studios code IDE
Install Angular CLI
Once done, the node & NPM installation after we install Angular CLI.
Why We need angular CLI
We use Angular CLI to create projects, generate library files. You can globally install the Angular CLI using the below command.
Npm install –g @angular/cli
Step 1
Now create an angular project, and open the terminal command prompt using the below command. Don’t forget adding angular-routing in your project.

Step 2
Next, we need the open created project in visual studio code and install the xlsx file reference npm using the following command.

Step 3
Once done the installation, we can add a reference in the app.component.ts file.

imports
Modules whose classes are needed by the component of this module.
selector
Selector tells Angular to create and insert an instance of this component where it finds <product-desc> tag.
For example, if an app’s HTML contains <product-desc></product-desc>, then Angular inserts an instance of the Product Description view between those tags.
templateUrl
It contains the path of this component’s HTML template.
styleUrls
We can specify the styles which are related to the current component.
Step 4
After open the app.component.html file and add the following code .


Mehrab ShaidaPosted Apr 18, 2022, 7:58 PM
Can you explain how to start reading excel file from specific row and also skip some cell or rows ? how to customize this please any idea?
Allan BarnardPosted Aug 24, 2020, 7:16 PM
In the ".ts" document, the line "this.file = event.target.files[0]" throws "propery 'file' does not exist on type 'AppComponent'". Any thoughts?
Satheesh ElumalaiPosted Feb 19, 2020, 10:52 PM
Nice article bro keep post