Excel.CellPropertiesFont interface
Stellt die format.font Eigenschaften von getCellProperties, getRowPropertiesundgetColumnProperties oder den format.font Eingabeparameter von setCellProperties,setRowProperties und dar.setColumnProperties
Hinweise
Eigenschaften
| bold | Stellt die |
| color | Stellt die |
| italic | Stellt die |
| name | Stellt die |
| size | Stellt die |
| strikethrough | Stellt die |
| subscript | Stellt die |
| superscript | Stellt die |
| tint |
Stellt die |
| underline | Stellt die |
Details zur Eigenschaft
bold
Stellt die format.font.bold Eigenschaft dar.
bold?: boolean;
Eigenschaftswert
boolean
Hinweise
color
Stellt die format.font.color Eigenschaft dar.
color?: string;
Eigenschaftswert
string
Hinweise
Beispiele
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/42-range/cell-properties.yaml
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getActiveWorksheet();
// Creating the SettableCellProperties objects to use for the range.
// In your add-in, these should be created once, outside the function.
const topHeaderProps: Excel.SettableCellProperties = {
// The style property takes a string matching the name of an Excel style.
// Built-in style names are listed in the `BuiltInStyle` enum.
// Note that a style will overwrite any formatting,
// so do not use the format property with the style property.
style: "Heading1"
};
const headerProps: Excel.SettableCellProperties = {
// Any subproperties of format that are not set will not be changed when these cell properties are set.
format: {
fill: {
color: "Blue"
},
font: {
color: "White",
bold: true
}
}
};
const nonApplicableProps: Excel.SettableCellProperties = {
format: {
fill: {
pattern: Excel.FillPattern.gray25
},
font: {
color: "Gray",
italic: true
}
}
};
const matchupScoreProps: Excel.SettableCellProperties = {
format: {
borders: {
bottom: {
style: Excel.BorderLineStyle.continuous
},
left: {
style: Excel.BorderLineStyle.continuous
},
right: {
style: Excel.BorderLineStyle.continuous
},
top: {
style: Excel.BorderLineStyle.continuous
}
}
}
};
const range = sheet.getRange("A1:E5");
// You can use empty JSON objects to avoid changing a cell's properties.
range.setCellProperties([
[topHeaderProps, {}, {}, {}, {}],
[{}, {}, headerProps, headerProps, headerProps],
[{}, headerProps, nonApplicableProps, matchupScoreProps, matchupScoreProps],
[{}, headerProps, matchupScoreProps, nonApplicableProps, matchupScoreProps],
[{}, headerProps, matchupScoreProps, matchupScoreProps, nonApplicableProps]
]);
sheet.getUsedRange().format.autofitColumns();
await context.sync();
});
italic
Stellt die format.font.italic Eigenschaft dar.
italic?: boolean;
Eigenschaftswert
boolean
Hinweise
name
Stellt die format.font.name Eigenschaft dar.
name?: string;
Eigenschaftswert
string
Hinweise
size
Stellt die format.font.size Eigenschaft dar.
size?: number;
Eigenschaftswert
number
Hinweise
strikethrough
Stellt die format.font.strikethrough Eigenschaft dar.
strikethrough?: boolean;
Eigenschaftswert
boolean
Hinweise
subscript
Stellt die format.font.subscript Eigenschaft dar.
subscript?: boolean;
Eigenschaftswert
boolean
Hinweise
superscript
Stellt die format.font.superscript Eigenschaft dar.
superscript?: boolean;
Eigenschaftswert
boolean
Hinweise
tintAndShade
Stellt die format.font.tintAndShade Eigenschaft dar.
tintAndShade?: number;
Eigenschaftswert
number
Hinweise
underline
Stellt die format.font.underline Eigenschaft dar.
underline?: Excel.RangeUnderlineStyle | "None" | "Single" | "Double" | "SingleAccountant" | "DoubleAccountant";
Eigenschaftswert
Excel.RangeUnderlineStyle | "None" | "Single" | "Double" | "SingleAccountant" | "DoubleAccountant"