JavaScript Excel Spreadsheet Use Cases: Media Industry
Tags: webdev, devops, javascript, tutorial
Published: 2023-07-26 19:38:34

---
canonical_url: https://developer.mescius.com/blogs/javascript-excel-spreadsheet-use-cases-media-industry
description: Learn about media industry use cases for JavaScript spreadsheet components, including content calendars and coverage tracking boards. See more from SpreadJS today.
---
SpreadJS, a JavaScript spreadsheet, can be used in many different applications and industries, with different features and use cases for almost any scenario. In this blog, we will show you how you can leverage the power and features of SpreadJS in an application for a company in the media industry. Specifically, this blog will show you how to create a content calendar to show when content is scheduled to be released and a tracker for article releases.

Download the [sample](https://developer.mescius.com/{localLink:umb://media/f0553ff9a53b4346b8299554a36ca373} "Media_SJS_07/14/23") to follow along with this blog.

## Setting Up SpreadJS

We can start by creating an HTML page and a JavaScript file to go along with it:

```
    <!doctype html>
    <html lang="en" style="height:100%;font-size:14px;">

    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link rel="stylesheet" type="text/css" href="./node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
        <link rel="stylesheet" type="text/css" href="styles.css">
        <script src="./node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script>
        <script src="app.js" type="text/javascript"></script>
    </head>
    <body>

        <div class="sample-tutorial">
            <div id="ss" style="width:100%;height:100%"></div>
        </div>
    </body>
    </html>
```

In this case, we can install SpreadJS in the application using NPM in a terminal:

```
    npm install @grapecity/spread-sheets
```

## Design the Calendar Template

The [SpreadJS Designer](/spreadjs/docs/spdesigner) makes creating templates really simple. We can start by creating the calendar in a sheet. Add a drop-down in a cell with a date that we can use to populate the calendar. The drop-down can be set as a custom name called “currentMonth”.

![Design the Calendar Template](https://files.grapecity.com/gc-website-media/ynmbt5id/01-media.gif?width=500&height=281.25)

We can then set up the days in a row, starting with Sunday and ending on Saturday. Once we have these two things, we can create a dynamic array function to populate the month with the correct dates. In this case, we will utilize the SEQUENCE and WEEKDAY functions. We can also format the days as Dates:

```
    =SEQUENCE(6,7,currentMonth-WEEKDAY(currentMonth)+1,1)
```

![Design the Calendar Template](https://files.grapecity.com/gc-website-media/unqppmul/02-media.gif?width=500&height=281.25)

In this example, we will also use a [range template](/spreadjs/demos/features/cells/range-template/purejs) for each day in the calendar to display specific data so we can do that now. Simply create a new sheet and format the cells in it as follows. We can then set up sheet binding and drag the fields into the cells from the side panel:

![Design the Calendar Template](https://files.grapecity.com/gc-website-media/p50aubdg/03-media.gif?width=500&height=267.56756756756755)

The last thing we can do in the SpreadJS Designer is to create a table with some data that we can use for the calendar. We can create another sheet with a table in it. To do this, follow these steps:

*   Add a sheet with the “+” icon in the sheet tab at the bottom
*   Highlight the cells where you want the table to go
*   Click on INSERT>Table and click “OK” in the popup menu
*   In the TABLE DESIGN Tab that opens up, change the Table Name by typing in the textbox at the top left

![Design the Calendar Template](https://files.grapecity.com/gc-website-media/d52db41v/04-media.png?width=500&height=361.6625310173697)

Now that we have the design of the calendar done, we can save it for loading in our application. To save it for editing later, we can go to FILE>Save>Save SJS File. In this case, I’ve called it “media_template.sjs”:

![Design the Calendar Template](https://files.grapecity.com/gc-website-media/xtcbm0ds/05-media.png?width=500&height=334.4086021505376)

To load the file in our application, we need to export it as a JS file. We can do this by going to FILE>Export>SpreadJS JSON>Export JavaScript File:

![Design the Calendar Template](https://files.grapecity.com/gc-website-media/mppdxokr/06-media.png?width=500&height=255.7624113475177)

We need to make sure we add a reference to this new file in our HTML file:

```
    <script src="media_template.js" type="text/javascript"></script>
```

## Creating and Setting the Range Template

Now that we have everything designed and loaded, we can create a range template based on the sheet we created that will load in each field from the table we made for the specific day in the calendar. Once we have that, we can set it as the formatter for all of the cells in the calendar:

```
    function createRangeTemplates(spread) {
    	var calendarSheet = spread.getSheetFromName("Content Calendar");
    	calendarSheet.suspendPaint();
    	var format = '=IFERROR(RANGEBLOCKSPARKLINE("Day Template"!$A$2:$C$4,'
    		+ 'OBJECT('
    		+ '"date",@,'
    		+ '"task",IFERROR(FILTER(calendarTable[Task],calendarTable[Date]=@),""),'
    		+ '"editor",IFERROR(FILTER(calendarTable[Editor],calendarTable[Date]=@),""),'
    		+ '"status",IFERROR(FILTER(calendarTable[Status],calendarTable[Date]=@),""),'
    		+ '"month",MONTH($B$4))),"")';
    	calendarSheet.getCell(6, 1).formatter(format);
    	for (var r = 6; r <= 11; r++) {
    		for (var c = 1; c <= 7; c++) {
    			calendarSheet.getCell(r, c).formatter(format);
    		}
    	}
    	calendarSheet.resumePaint();
    }
```

This will result in a correctly formatted calendar with the data that we created:

![Creating and Setting the Range Template](https://files.grapecity.com/gc-website-media/enlp2umf/07-media.png?width=500&height=347.27703235990526)

## Media Coverage Tracker

We can now add the last piece of this application: the media coverage tracker. This shows all of the articles and their status’ for tracking purposes. We can start by opening our .SJS file in the SpreadJS Designer, creating a new sheet and adding two tables to it, one called “ArticlesPlanned” and the other “ArticlesLive”. This can be done with the same process we used earlier:

![Media Coverage Tracker](https://files.grapecity.com/gc-website-media/11xffepk/08-media.png)

We can save this file and export it to JS as we did before. This should now load into our application with the new sheet. We can now start adding data to these tables, and we can do so by creating an object to bind the tables to:

```
    function createMediaCoverageTables(spread) {
    	var mediaCoverageTrackerSheet = spread.getSheetFromName("Media Coverage Tracker");
    	var mediaCoverageData = {
    		articlesLive: [
    			{article: "Businesses and Spreadsheets", publication: "NYTimes", type: "Feature", date: "7/3/2023", status: "Live"},
    			{article: "Top Spreadsheet Software 2023", publication: "Forbes", type: "Review", date: "7/6/2023", status: "Live"},
    			{article: "New Spreadsheet Software Releases", publication: "WIRED", type: "Release", date: "7/13/2023", status: "Live"},
    			{article: "Upcoming Excel Changes", publication: "CNET", type: "Broadcast", date: "7/17/2023", status: "Live"}			
    		],
    		articlesPlanned: [
    			{article: "The Best Spreadsheet Functions for Your Workbook", publication: "The Verge", type: "Review", date: "7/20/2023", status: "Planned"},
    			{article: "Spreadsheets in Layman's Terms", publication: "Medium", type: "Feature", date: "7/24/2023", status: "Planned"}
    		]
    	};
    	...
    }
```

Now that we have that data, we can get the tables from the sheet, create the table columns, and bind each table to its own data source from the object we created above:

```
    function createMediaCoverageTables(spread) {
    	...
    	mediaCoverageTrackerSheet.suspendPaint();
    	var tableArticlesLive = mediaCoverageTrackerSheet.tables.findByName("ArticlesLive");
    	var tableArticlesPlanned = mediaCoverageTrackerSheet.tables.findByName("ArticlesPlanned");
    	var tc1 = new GC.Spread.Sheets.Tables.TableColumn();
    	tc1.name("Article");
    	tc1.dataField("article");
    	var tc2 = new GC.Spread.Sheets.Tables.TableColumn();
    	tc2.name("Publication");
    	tc2.dataField("publication");
    	var tc3 = new GC.Spread.Sheets.Tables.TableColumn();
    	tc3.name("Type");
    	tc3.dataField("type");
    	var tc4 = new GC.Spread.Sheets.Tables.TableColumn();
    	tc4.name("Date");
    	tc4.dataField("date");
    	tc4.formatter("M/d/yyyy");

    	tableArticlesLive.autoGenerateColumns(false);
    	tableArticlesLive.bind([tc1, tc2, tc3, tc4], 'articlesLive', mediaCoverageData);
    	tableArticlesPlanned.autoGenerateColumns(false);
    	tableArticlesPlanned.bind([tc1, tc2, tc3, tc4], 'articlesPlanned', mediaCoverageData);

    	mediaCoverageTrackerSheet.resumePaint();
    }
```

Once we run this code, we’ll have the media track and content calendar loaded in the workbook with all of their data:

![Media Coverage Tracker](https://files.grapecity.com/gc-website-media/dhkobwmo/09-media.png?width=500&height=433.2386363636364)

That is all it takes to create a simple media application with SpreadJS! This can be expanded upon with more functionality and data, but this is the perfect starting point for implementing your own application. Check out our [documentation](/spreadjs/docs/overview) for more information about the features of SpreadJS, and try out our [demos](/spreadjs/demos/) to see features in action.