writeSpreadsheet Documentation
Overview
The writeSpreadsheet function is designed to create a Google Sheet in Google Drive. This function enhances user data management by providing a structured way to export datasets into a formatted spreadsheet with proper headers and typed cells within a specified Intuidy folder. The function seamlessly integrates with cloud services, enabling efficient data storage and accessibility.
Settings
The writeSpreadsheet component has the following settings:
1. fileName
- Input Type: String
- Purpose: This setting specifies the name of the Google Sheet file that will be created in Google Drive. If no value is provided by the user, it defaults to
'export'. - Effects of Changing It: Changing the
fileNameaffects how the exported Google Sheet is named in Google Drive. This can assist users in organizing their files much better, as a descriptive filename could make file retrieval easier. - Default Value: 'export'
2. subfolder
- Input Type: String (optional)
- Purpose: This optional setting allows the user to define a specific subfolder within Google Drive where the new spreadsheet will be saved. This feature is crucial for users who require their files saved in a particular location or want to maintain an organized file structure.
- Effects of Changing It: Specifying a
subfolderensures that the Google Sheet is saved in the intended location. If not specified, the file will be saved in the root directory of the user's Google Drive. - Default Value: None (if not provided, the file is saved to the root directory)
How it Works
The writeSpreadsheet function operates asynchronously, using the writeFileNode function to handle the specifics of file writing. Here’s a brief outline of the workflow:
-
Inputs: The function accepts an array of objects (datasets) through the
inputsparameter. These datasets represent the data that will be written to the Google Sheet. -
Configuration: It merges provided
configsettings using the spread operator, ensuring that any provided configurations are applied while assigning default values where necessary. -
Context: The
contextparameter allows for additional metadata or context settings that might be required during the file writing process. -
The final execution results in creating a Google Sheet with the specified format, saved according to the configurations given.
Expected Data
The writeSpreadsheet function expects the following input data:
- Data: An array of objects representing the dataset that needs to be exported to the Google Sheet. Each object corresponds to a row in the spreadsheet, where the keys of the object become the column headers, and the values represent the entries in those columns.
Use Cases & Examples
Use Cases
-
Sales Data Reporting: A sales team can use
writeSpreadsheetto export weekly sales data, formatted with headers such as "Date", "Product Name", "Revenue", etc., allowing for further analysis of sales trends. -
Project Management Tracking: A project manager can export project status updates to a Google Sheet, capturing information such as task names, statuses, assignments, and deadlines to enhance project visibility.
-
Customer Feedback Collection: A marketing team can utilize their feedback collection framework to directly write customer responses into a structured spreadsheet for easier analysis and reporting.
Example Configuration
Use Case: Sales Data Reporting
Assuming a business wants to export its weekly sales data for better tracking and decision-making, they can configure the writeSpreadsheet component as follows:
Sample Configuration Data:
const inputs = [
{ date: '2023-10-01', productName: 'Product A', revenue: 150 },
{ date: '2023-10-01', productName: 'Product B', revenue: 200 },
{ date: '2023-10-02', productName: 'Product A', revenue: 100 },
{ date: '2023-10-02', productName: 'Product C', revenue: 250 },
];
const config = {
fileName: 'Weekly_Sales_Report_October_2023',
subfolder: 'SalesReports',
};
const context = {};In this example:
- The
fileNameis set toWeekly_Sales_Report_October_2023, ensuring clarity in identifying the report. - The
subfolderis specified asSalesReportsfor organized access within Google Drive. - The
inputsarray contains several sales entries, which will structure the Google Sheet as required, with appropriate headings for each column.
This comprehensive setup enables sales teams to efficiently log, analyze, and report on sales data, enhancing operational efficiency.