Generate 20 - 16 digit numbers. Format them. Then Move Column
I've never used the sheet.moveColumn() command before. I found it rather interesting. Anyway this function generates total of 20 16 digit numbers in A1:A20 and moves them to column F. Interestingly enough they end up in column E since it also deletes columnA. I used a generateString() function that I wrote previously to generate the sixteen digit numbers.
function formatThenMove() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
var rg=sh.getRange(1,1,20,1);//A1:A20
var vA=rg.getValues();
var fA=rg.getNumberFormats();
for(var i=0;i<vA.length;i++) {
vA[i][0]=generateString();//setup for 16 digits
fA[i][0]="@";//here's the format for raw text
}
rg.setValues(vA);//set values
rg.setNumberFormats(fA);//set formats
sh.moveColumns(rg, 6);//move to column F
}
function generateString(sObj){
var sObj=sObj || {uppercase:false,lowercase:false,numbers:true,allothers:false,custom:false,custxt:'',slctlen:16};//defaults to 16 digit number
var upperCase='ABCDEFGHIJKLMNOPQRSTUVWXYZ';//26
var lowerCase='abcdefghijklmnopqrstuvwxyz';//26
var numBers='0123456789';//10
var allOthers='~@#$%^&*()_-+={[}]|\:;"<,>.?/';//29
var s='';
var o='';
s+=(sObj.uppercase)?upperCase:'';
s+=(sObj.lowercase)?lowerCase:'';
s+=(sObj.numbers)?numBers:'';
s+=(sObj.allothers)?allOthers:'';
s+=(sObj.custom)?sObj.custxt:'';
for(var i=0;i<sObj.slctlen;i++){
o+=s.charAt(Math.floor(Math.random()*s.length));
}
Logger.log(o);
return o;
}
I don't see the behavior you mention about the format changing to scientific notation. So you didn't achieve a minimal complete verifiable example.