Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
excel-calculator
Advanced tools
ExcelCalculator is an npm package for dynamic Excel data manipulation and calculation, powered by exceljs and mathjs.
excel-calculator is an npm package designed to facilitate the manipulation and calculation of Excel sheet data programmatically. Leveraging the powerful exceljs
and mathjs
libraries, it allows users to read Excel files, modify cell values, apply formulas, and perform calculations dynamically.
In many industries, Excel files are a cornerstone for data storage, manipulation, and analysis. However, manual data entry and calculations in Excel can be time-consuming, error-prone, and inefficient, especially when dealing with large datasets or complex calculations. Automation scripts can significantly improve these processes, but they often require a bridge between the programming logic and the Excel file format.
excel-calculator fills this gap by providing an easy-to-use, programmatic way to interact with Excel files. It allows developers to:
By leveraging the power of exceljs
for Excel file manipulation and mathjs
for performing mathematical operations, excel-calculator simplifies the task of working with Excel files in a programmatic environment. It is an essential tool for developers looking to automate Excel-related tasks, integrate Excel functionality into applications, or build custom solutions based on Excel files.
To install excel-calculator, run the following command in your project directory:
npm install excel-calculator
First, import and create an instance of excel-calculator
with the path to your Excel file and the worksheet name you intend to work with:
import { ExcelCalculator } from 'excel-calculator';
const calculator = new ExcelCalculator('path/to/your/file.xlsx', 'Sheet1');
To modify or read cell values:
// Set a single cell value
calculator.setCellValue('A1', 100);
// Get a cell value
const value = calculator.getCellValue('A1');
console.log(value); // Output: 100
You can apply formulas to cells and calculate their values:
// Set a formula for a cell
calculator.setCellFormula('B1', 'A1*2');
// Calculate all formulas in the worksheet
calculator.calculate();
// Get the calculated value
const calculatedValue = calculator.getCellValue('B1');
console.log(calculatedValue); // Output: 200
A complete workflow from initializing the calculator, setting values and formulas, to calculating and retrieving values:
const calculator = new ExcelCalculator('path/to/file.xlsx', 'Sheet1');
await calculator.init();
calculator.setCellValue("A1", 100);
calculator.setCellValue("A2", 200);
calculator.setCellValue("A3", 300);
calculator.setCellFormula("B1", "A1*2");
calculator.setCellValue("B2", 30);
calculator.setCellValue("B3", 100);
calculator.setCellFormula("C1", "AVERAGE(A1:A3, B1:B3)");
calculator.calculate();
console.log(calculator.getCellValue("C1")); // Output: 200
console.log(calculator.getCellValue("B1")); // Output: 155
Another example of setting a worksheet with initial values and formulas and calculating the result:
const calculator = new ExcelCalculator('path/to/file.xlsx', 'Sheet1');
await calculator.setWorksheet({
A1: { value: 2 },
B1: { value: 3 },
C1: { formula: "A1+B1" },
});
const result = calculator.calculate();
console.log(result.C1.value); // Output: 5
Refer to the code comments for detailed API usage and method descriptions.
Contributions to improve excel-calculator are welcome. Please follow the standard process for contributing to open source projects:
git checkout -b feature/AmazingFeature
).git commit -am 'Add some AmazingFeature'
).git push origin feature/AmazingFeature
).Distributed under the custom License. See LICENSE
file in GitHub for more information.
Nitai Aharoni - nitaiaharoni1@gmail.com
Project Link: https://github.com/nitaiaharoni1/excel-calculator
FAQs
ExcelCalculator is an npm package for dynamic Excel data manipulation and calculation, powered by exceljs and mathjs.
The npm package excel-calculator receives a total of 0 weekly downloads. As such, excel-calculator popularity was classified as not popular.
We found that excel-calculator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.