Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda