I have file in google sheets(img 1).
https://i.sstatic.net/1j8ny.png [1]
i wrote script which is converting marked columns to word (i need to mark only 1st 4 columns becuase its going to be on sticker) (img 2)
https://i.sstatic.net/GnIXo.png [2]
this is the code:
SpreadsheetApp.getUi()
.createMenu('Drukowanie odpadów')
.addItem('Drukuj zazaczone odpady - ZAZNACZ 4 pierwsze kolumny!', 'sprawdz')
.addToUi();
/**
* @NotOnlyCurrentDoc
*/
function sprawdz() { //zbiera dane z zaznaczenia (4 kolumny) w arkuszu GoogleSheet, uzupełnia GoogleDoc danymi
// otworzenie dokumentu w google Doc, do którego będą przenoszone zaznaczone kolumny
var doc = DocumentApp.openByUrl("https://docs.google.com/document/d/WORD_ID/edit");
var body = doc.getBody();
//CZYSZCZENIE ORAZ USTAWIENIE WYMIARÓW ETYKIETY
body.clear();
body.setPageHeight(100);
body.setPageWidth(260);
body.setMarginLeft(0.1);
body.setMarginRight(0.1);
body.setMarginTop(0.01);
body.setMarginBottom(0.01);
var sheet = SpreadsheetApp.getActiveSheet();
var selection = sheet.getSelection();
var data = selection.getActiveRange().getValues();
//PIERWSZE UZUPEŁNIENIE DOKUMENTU
body.getParagraphs()[0].appendText(' {nr_odpadu} {dlugosc}').setFontSize(13);
body.appendParagraph(' {kolor}').setAlignment(DocumentApp.HorizontalAlignment.LEFT).editAsText().setFontSize(10);
body.appendParagraph(' {profil}').setAlignment(DocumentApp.HorizontalAlignment.LEFT).editAsText().setFontSize(10);
body.appendParagraph(' ').setAlignment(DocumentApp.HorizontalAlignment.LEFT).editAsText().setFontSize(35);
//PETLA KTORA ZBIERA DANE Z ARKUSZA I UMIESZCZA JE W ODPOWIEDNIM MIEJSCU W DOKUMENCIE
for (var i = 0 ; i < data.length; i++) {
body.replaceText('{nr_odpadu}', data[i][0]);
body.replaceText('{profil}', data[i][1]);
body.replaceText('{kolor}', data[i][2]);
body.replaceText('{dlugosc}', data[i][3]+'mm');
//jeśli dotrzemy do końca listy, to nie ma potrzeby dalszego drukowania
if (i != data.length-1){
body.appendParagraph(' {nr_odpadu} {dlugosc}').setAlignment(DocumentApp.HorizontalAlignment.LEFT).editAsText().setFontSize(13);
body.appendParagraph(' {kolor}').setAlignment(DocumentApp.HorizontalAlignment.LEFT).editAsText().setFontSize(10);
body.appendParagraph(' {profil}').setAlignment(DocumentApp.HorizontalAlignment.LEFT).editAsText().setFontSize(10);
body.appendParagraph(' ').setAlignment(DocumentApp.HorizontalAlignment.LEFT).editAsText().setFontSize(35);
}
}
}
is there any option to insta print with printer the word document from google sheets script editor?
F.e i mark 4 columns i run the script and it print me the sticker. Im using printer "Zebra GK420t"
Im converting it to word document because when i was converting it to pdf i couldnt change page size to height 100 and weight 260 and i dontk now how to place the things like on screen 2
Or mby there is a way to insta print marked columns without creating word/pdf ?