1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GAS 帳票作成コード

Last updated at Posted at 2019-03-04

gasで、 下記図のようなRawデータを帳票化するjavaを書いております。

スクリーンショット 2019-03-04 13.16.18.png

上記のRawデータを下記のような帳票に自動で入力させるように構築したいのですが上手くいきません。
*同品番であれば、カラー、香り毎の売上を帳票に入力後次の品番へ移るといった具合です。

スクリーンショット 2019-03-04 13.12.35.png

コードは下記の通りです。

function test() {
  var sheet,sheet2,gyo,col,color,shee,col2,gyo2,gedai,iro,suu,mei,hinban,joudai,matome,t,joudai2,s
  var lastRow 
  var s1,s2,s3,s4,s5,s6
  
  gyo = 2;
  col = 2;
  gyo2 = 2;
  col2 = 2;
  t = 0;
  s = 0;
  
  
  
  sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('データ貼り付けシート');
  sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('帳票シート');
  lastRow = sheet.getLastRow()
  
   for (var gyo=2; gyo<=lastRow; gyo++) { 

  joudai = sheet.getRange(gyo,1).getValue();
  joudai2 = sheet.getRange(gyo+1,1).getValue();
  hinban = sheet.getRange(gyo,2).getValue();
  gedai = sheet.getRange(gyo,3).getValue();
  mei = sheet.getRange(gyo,4).getValue();
  suu = sheet.getRange(gyo,4).getValue();
  color = sheet.getRange(gyo,8).getValue();
  matome = sheet.getRange(gyo,9).getValue();
  
  s1 = sheet2.getRange(gyo2+9,col2+s).setValue(joudai);
  s2 = sheet2.getRange(gyo2+5,col2+s).setValue(hinban);
  s3 = sheet2.getRange(gyo2+11,col2+s).setValue(gedai);
  s4 = sheet2.getRange(gyo2+7,col2+s).setValue(mei);
  s5 = sheet2.getRange(gyo2,col2+3).setValue(suu);   
  s6 = sheet2.getRange(gyo2+13+t,col2+s).setValue(matome);
  gyo + 1;
  s + 1;
    
    if(gyo != gyo){s+10;}else{col2+2;gyo=2;s=2;}
    
    
    }
    
}

どなたかご教授願えましたら、幸甚です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?