Copy link to clipboard
Copied
Hi all!
I need a bit of help with appliedCellStyle. I have a script to make calendars (I know, there's a superb Calendar script yet, but this is MY script, and it covers my special needs). It works fine... or almost. The last version changes (big changes indeed, but more in concept than in programming) have some collateral damages. In the case of cells with 2 days in it, I apply 2 different paragraph styles, one for the day in the upper and other for the downer and a especial cell style, with a diagonal line and reduced margins. There's 1 special cell styles for every the 2 table sizes, the big principal month and the previous and next month, more littles.
In previous versions all the styles were applied fine. Now, without aparent reason, the specials cell styles doesn't work. I tried to override, to apply [None] style before to apply special style... all I have found in this forum. Nothing works.
That's the code that applies styles:
while (dias_en_mes.length) {
t.cells[celda].appliedCellStyle = estilo_celda;
t.cells[celda].contents = String(dia);
t.cells[celda].insertionPoints.item(0).appliedParagraphStyle = doc.paragraphStyles.item(estilo_par);
// estilo de caracter segun el dia
if (dias_en_mes[0] == 'domingo' || dias_en_mes[0] == 'festivo nacional')
t.cells[celda].words[0].appliedCharacterStyle = doc.characterStyles.item('CAL_fiesta nacional');
else if (dias_en_mes[0] == 'festivo local')
t.cells[celda].words[0].appliedCharacterStyle = doc.characterStyles.item('CAL_fiesta local');
else
t.cells[celda].words[0].appliedCharacterStyle = doc.characterStyles.item('CAL_normal');
// si hay evento asociado a ese dia y está activado en la paleta
if (eventos_flag && año_completo[mes_cal].dia[dia].evento) {
// el estilo ['Ninguno'] en realidad es solo un enlace. El estilo [0] funciona en cualquier idioma
t.cells[celda].words[0].appliedCharacterStyle = doc.characterStyles[0];
t.cells[celda].insertionPoints.item(0).appliedParagraphStyle = doc.paragraphStyles.itemByName(año_completo[mes_cal].dia[dia].evento);
}
// celdas de la ultima fila que tienen 2 dias.
// La distancia de lunes a domingo es 6, no 7
if (celdas_dobles && celda == celdas_disponibles - 6 + ajuste_dias_dobles[0]) {
t.cells[celda].appliedCellStyle = estilo_celda_doble; // no funciona bien
// no se xq el estilo de celda no aplica bien y no sale la linea, la pongo a mano
t.cells[celda].topRightDiagonalLine = true;
t.cells[celda].words[0].appliedParagraphStyle = doc.paragraphStyles.item(estilo_par_arriba);
t.cells[celda].contents += '\r' + String(dia + 7);
t.cells[celda].words[1].appliedParagraphStyle = doc.paragraphStyles.item(estilo_par_abajo);
// no podemos usar dias_en_mes[dia+7] porque dias_en_mes mengua, no existe dia+7
if (año_completo[mes_cal].dia[dia + 7].tipo == 'domingo' || año_completo[mes_cal].dia[dia + 7].tipo == 'festivo nacional')
estilo_car = 'CAL_fiesta nacional';
else if (año_completo[mes_cal].dia[dia + 7].tipo == 'festivo local')
estilo_car = 'CAL_fiesta local';
else
estilo_car = 'CAL_normal';
t.cells[celda].words[1].appliedCharacterStyle = doc.characterStyles.itemByName(estilo_car);
dias_en_mes.pop(); // eliminamos el ultimo elemento de la tabla de dias, ya procesado
ajuste_dias_dobles.shift(); // eliminamos el primer elemento de la tabla de dobles, ya procesado
}
celda++;
dia++;
dias_en_mes.shift(); // eliminamos simpre el elemento 0 del array de dias, asà siempre referenciamos al 0 en el bucle
} // fin while
I apply manually the diagonal line 'cause it's not applied by script (not showed in the previous screenshoot). That's how it shows with the special cell style manually applied (black backgrounded cell 'cause it's selected).
That's the if that does the job with double day cells:
Never mind mates!
I have found a place in middle of the 1.800 lines of the script that say:
Copy link to clipboard
Copied
Never mind mates!
I have found a place in middle of the 1.800 lines of the script that say: