Display cell information within the listFilesInFolder method

Not only does this formula successfully list all the files in a folder, but can it also retrieve specific cell data from each file within the same script?

function listFilesInFolder() {
  var folder = DocsList.getFolder("1- Summaries");
  var contents = folder.getFiles();

  var file;
  var data;

  var sheet = SpreadsheetApp.getActiveSheet();
  sheet.clear();

  sheet.appendRow(["Name", "Date", "Size", "URL", "Download", "Description", "Type"]);

  for (var i = 0; i < contents.length; i++) {
    file = contents[i];

    if (file.getFileType() == "SPREADSHEET") {
      continue;
    }

    data = [ 
      file.getName(),
      file.getDateCreated(),
      file.getValue(B10),  **(HERE I'M TRYING TO RETRIEVE DATA, BUT IT'S NOT WORKING)**
      file.getUrl(),
      "https://docs.google.com/a/acme.com/spreadsheet/ccc?key=" + file.getId(),
      file.getDescription(),
      "audio/mp3"
    ]

    sheet.appendRow(data);

Answer №1

Able to access the data from the spreadsheet.

Instead of if (file.getFileType()..., insert the following:

let cellValue;
if (file.getFileType() === "SPREADSHEET") {
  cellValue = SpreadsheetApp.openById(file.getId()).getSheetByName("NameOfSheet")
      .getRange("B10").getValue();
} else {
  cellValue = null; // set a default value here!
}
  ...

Update your data array with this information:

data = [ 
  file.getName(),
  file.getDateCreated(),
  cellValue,
...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A guide on transforming a MySQL query into a JPA named query

There is a single Order table in my database. order_id | customer_id | submit_date | order_number | .... Currently, I am retrieving all records based on the customer_id using a jpa named query. public List<Order> readOrders(Long customerId){ Qu ...

Using a jQuery hover effect to slide a span element

I have designed custom share buttons to enhance the appearance of the traditional like, tweet, pin, etc. However, I am facing an issue with hover functionality in a jsfiddle demo. The buttons almost function as intended, but I need the span element to rema ...

What steps do I need to follow to configure Android sources in IntelliJ?

Currently, I am embarking on a project that requires me to create a customized version of Android. I am specifically interested in setting up the source code in Intellij. To obtain the source code, I have referenced the Android Open Source Project along w ...

Wait for AngularJS to load when the background image of a div becomes visible

Currently, I am utilizing the ng-repeat feature to fetch data from a $http.post request and then save it to the $scope.data variable. <div ng-repeat="key in [] | range:data.pages"> <div class="pageBackground" id="page_{{ (key+1) }}" ng-style= ...

Error: The function _firebase.db.collection is not defined and cannot be executed

I am a beginner in react-native and JS. Currently, I am working on a chat app project and attempting to implement a button that triggers the creation of a new chat using the provided function: const createChat = async () =>{ await db .collection ...

Send a POST request and handle the response in a Node.js environment using EJS

Currently, I am working on an Index Site (EJS) where I have implemented a select form that reads an array. In my index.ejs file, the code looks like this: <html> <head> </head> <body> <center> <fo ...

What is the best way to adjust the main method in order to receive input and output directly from the command line?

I am looking for a way to read input and output file names from the command line instead of hard coding them as infile and outfile. Can you provide guidance on how to accomplish this? /** * reads a file and creates a histogram from it * @param args st ...

After completing the installation of "node-pty" in an electron-forge project on Linux, I noticed that the pty.node.js file is not present. What is the proper way to install node-pty

Following the installation of node-pty, an external module utilized to generate pseudo terminals with Node.js in a boilerplate electron-forge project, I encountered an issue. The error indicated that a core module within node-pty was attempting to import a ...

Exploring the world with an interactive map in R, incorporating Shiny and leaflet

I'm currently attempting to integrate a Google layer as the base layer for a Leaflet map in Shiny R. To achieve this, I've been utilizing shinyJs to inject a JavaScript script into my R code and add the map. However, I'm facing an issue wher ...

Execute jQuery code only when a child element within the parent container is clicked

Within a div section, I have included various child controls like dropdowns and check boxes. I am seeking to implement some jQuery code that will be triggered when any of the child elements are clicked, excluding clicks on the empty space within the div. ...

Is it feasible to have multiple versions of React coexisting in a monorepo?

I have a monorepo set up with npm workspaces: ├─ lib │ └─ Foo └─ src ├─ App └─ Web I am looking to upgrade the Web package to React 18 while keeping App on React 17 My current dependencies are as follows: ├─ lib │ └ ...

the function will fail to execute if the id parameter is missing

Error : Cannot read property id of undefined How can I modify this function to handle cases where id is not present or the foundApplication array is empty? I am not allowed to make changes to the getDocument function async function getApplicationByCbax ...

Transform a checkbox input into two distinct buttons

I am trying to change the input checkbox that toggles between light and dark mode into two separate buttons. How can I achieve this functionality? Check out the demo here: https://jsfiddle.net/ot1ecnxz/1 Here is the HTML code: <input type="checkb ...

Java - Evaluating the Date(0) retrieved from a null database entry

My task is to retrieve all records from a selected collection where the something_date field is null, but in MongoDB, the value for this field is shown as "something_date" : null. However, when retrieving these null values for something_date, an Epoch date ...

Tips for transferring control from the first button to a JavaScript function when clicking the second button

As a newcomer to javascript and html, I have a simple query. In my javascript file, there is a snippet of code that looks like this: function setColor(btn, color) { if (btn.style.backgroundColor == "#f47121") { btn.style.backgroundColor = color; } els ...

Display a block by using the focus() method

My objective is : To display a popin when the user clicks on a button To hide the popin when the user clicks elsewhere I previously implemented this solution successfully: Use jQuery to hide a DIV when the user clicks outside of it However, I wanted to ...

Exploring the Methods to Monitor Variables in Framework7 Store

Currently, I am in the process of developing my app and have opted to utilize the new built-in store system instead of relying on Vuex. I have a variable that undergoes frequent changes and previously used the following code when working with Vuex: store.w ...

I am unsuccessful in transferring the "side-panel content" to the side panel located on the main menu page

I am facing an issue where I want to pass My left and right Panel to the main menu page (dashboard), but it is not working as expected. The problem arises because the first page that needs to be declared is the login page (/ root) in my case. If I pass it ...

The smooth transition of my collapsible item is compromised when closing, causing the bottom border to abruptly jump to the top

Recently, I implemented a collapsible feature using React and it's functioning well. However, one issue I encountered is that when the collapsible div closes, it doesn't smoothly collapse with the border bottom moving up as smoothly as it opens. ...