I hesitate to ask, but in order to solve my issue, I must seek help. My current dilemma involves reading data from an Excel file within my Angular project. This particular file is stored in the assets directory.
Although I am aware of how to access files from a folder, I seem to be encountering challenges in this scenario.
Within app.component.ts, specifically in the ngOnInit function, I attempt to fetch the file:
ngOnInit() {
this.http.get('assets/dataTest.xlsx').subscribe((data: any) => {
console.log("get: " + data);
});
}
My understanding leads me to believe that the following code should be utilized within the http.get method:
const reader: FileReader = new FileReader();
reader.onload = (e: any) => {
console.log("READ " + e);
};
reader.readAsBinaryString(data);
However, this implementation proves to be unsuccessful as it results in an error message:
ERROR TypeError: Failed to execute 'readAsBinaryString' on 'FileReader': parameter 1 is not of type 'Blob'.
I kindly request assistance with effectively reading data from an Excel file situated within the assets directory.