Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
How do I set a cell value as Print Title instead of a URL

As the title suggest, I want to be able to download the pdf file this code creates with the title I took from a cell value of its sheet. Thanks in advance!

  function printSelectedRange() {
  SpreadsheetApp.flush();
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var formS = ss.getActiveSheet();
  var range = formS.setActiveRange(formS.getRange("B7:J58"));

  var gid = formS.getSheetId();
    var printRange = objectToQueryString({
    'c1': range.getColumn() - 1 ,
    'r1': range.getRow() - 1,
    'c2': range.getColumn() + range.getWidth() -1 ,
    'r2': range.getRow() + range.getHeight() 

  });
  var url = ss.getUrl().replace(/edit$/, '') + 'export?format=pdf' + PDF_OPTS + printRange + "&gid=" + gid;

  var htmlTemplate = HtmlService.createTemplateFromFile('js');
  htmlTemplate.url = url;
  SpreadsheetApp.getUi().showModalDialog(htmlTemplate.evaluate().setHeight(10).setWidth(400),'Purchase Request by ');
}

function objectToQueryString(obj) {
  return Object.keys(obj).map(function(key) {
    return Utilities.formatString('&%s=%s', key, obj[key]);
  }).join('');
}
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <script>
  window.open('<?=url?>','_blank','width=800, height=600');
  google.script.host.close();
</script>
  </body>
</html>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda