This project is a React application that displays tasks from a Google Sheet. It's designed to be embedded as a sidebar in Google Sheets using Google Apps Script.
To link this project with your Google Sheet, you'll need to use Google Apps Script. Follow these steps:
-
Open your Google Sheet.
-
Go to Extensions > Apps Script.
-
This will open the Apps Script editor. If you have an existing
Code.gsfile, replace its content. Otherwise, create a new script file namedCode.gs. -
Paste the following code into
Code.gs:function onOpen() { const ui = SpreadsheetApp.getUi(); ui.createMenu('Task Manager') .addItem('Open Task Sidebar', 'showSidebar') .addToUi(); } function showSidebar() { const data = getAllTasks(); const stringfied = JSON.stringify(data); // console.log(stringfied); // For debugging const encoded = encodeURIComponent(stringfied); // console.log(encoded); // For debugging const html = HtmlService.createHtmlOutput(` <iframe src="https://nirmalyohannan.github.io/google-sheet-tasks/?data=${encoded}" width="100%" height="600" style="border: none;"></iframe> `).setTitle("React Task Viewer"); SpreadsheetApp.getUi().showSidebar(html); } function getAllTasks() { const sheet = SpreadsheetApp.getActiveSheet(); const data = sheet.getDataRange().getValues(); const headers = data[0]; return data.slice(1).map(row => { const obj = {}; headers.forEach((header, index) => { obj[header] = row[index]; }); return obj; }); }
-
Save the script (File > Save or Ctrl+S/Cmd+S).
-
Refresh your Google Sheet. You should now see a new menu item: Task Manager > Open Task Sidebar.
-
Clicking Open Task Sidebar will open the task viewer in the sidebar, populated with data from your active sheet.
The React application is hosted on GitHub Pages and can be accessed via the following URL structure within the Apps Script:
https://nirmalyohannan.github.io/google-sheet-tasks/?data=${encoded_data}
Where ${encoded_data} is the URL-encoded JSON string of your task data.
- The
getAllTasks()function inCode.gsreads all data from the active Google Sheet. - It assumes the first row contains headers (column names).
- It converts each subsequent row into a JSON object where keys are the headers and values are the cell contents for that row.
- An array of these JSON objects is created.
- This array is then
JSON.stringify()-ed andencodeURIComponent()-ed. - The resulting encoded string is passed as a URL query parameter named
datato the React application's URL. - The React application (
App.tsx) then retrieves thisdataparameter, decodes it, parses the JSON, and displays the tasks.
For the application to work correctly, your Google Sheet should have the following columns in the first row (headers). The order of columns does not strictly matter as long as the headers match these names, but the data types are important:
Date: The date of the task. (e.g.,2025-05-20or any format recognized bynew Date()in JavaScript. The app will format it toDD Mon YYYYlike20 May 2025).Task: A short description or title of the task (e.g.,Clean 1st floor).Category: The category of the task (e.g.,Other,Work,Personal).Duration(Minute): The duration of the task in minutes (e.g.,120). This must be a number.Description: A more detailed description of the task (e.g.,-Book shelf cleaned).
Example Sheet Structure:
| Date | Task | Category | Duration(Minute) | Description |
|---|---|---|---|---|
| 2025-05-20 | Clean 1st floor | Other | 120 | -Book shelf cleaned |
| 2025-05-21 | Project Meeting | Work | 60 | Discuss project plan |
| 2025-05-21 | Grocery Shopping | Personal | 45 | Buy weekly groceries |
To run this project locally:
- Clone the repository.
- Install dependencies:
npm install - Start the development server:
npm run dev
To build the project for production:
npm run build
This will create a dist folder with the static assets.
The project is configured to deploy to GitHub Pages using the gh-pages package.
- Ensure your
package.jsonhas the correcthomepagefield (e.g.,"homepage": "https://your-username.github.io/your-repo-name"). For this project, it is"homepage": "https://nirmalyohannan.github.io/google-sheet-tasks". - Run the deploy script:
npm run deploy
This will build the project and push the contents of the dist folder to the gh-pages branch of your repository.