Word.Style class
Représente un style dans un document Word.
- Extends
Remarques
[ Ensemble d’API : WordApi 1.3 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Applies the specified style to a paragraph.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to apply.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else if (style.type != Word.StyleType.paragraph) {
console.log(`The '${styleName}' style isn't a paragraph style.`);
} else {
const body: Word.Body = context.document.body;
body.clear();
body.insertParagraph(
"Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.",
"Start"
);
const paragraph: Word.Paragraph = body.paragraphs.getFirst();
paragraph.style = style.nameLocal;
console.log(`'${styleName}' style applied to first paragraph.`);
}
});
Propriétés
| automatically |
Spécifie si le style est automatiquement redéfini en fonction de la sélection. |
| base |
Spécifie le nom d’un style existant à utiliser comme mise en forme de base d’un autre style. |
| borders | Spécifie un |
| built |
Obtient si le style est un style intégré. |
| context | Contexte de requête associé à l’objet . Cela connecte le processus du complément au processus de l’application hôte Office. |
| description | Obtient la description du style. |
| font | Obtient un |
| frame | Renvoie un |
| has |
Spécifie si le vérificateur d’orthographe et de grammaire ignore le texte mis en forme avec ce style. |
| in |
Indique si le style est un style intégré qui a été modifié ou appliqué dans le document ou un nouveau style qui a été créé dans le document. |
| language |
Spécifie une |
| language |
Spécifie une langue d’Asie de l’Est pour le style. |
| linked | Obtient si le style est un style lié qui peut être utilisé à la fois pour la mise en forme des paragraphes et des caractères. |
| link |
Spécifie un lien entre un paragraphe et un style de caractère. |
| list |
Retourne le niveau de liste pour le style. |
| list |
Obtient un |
| locked | Spécifie si le style ne peut pas être modifié ou modifié. |
| name |
Obtient le nom du style dans la langue de l’utilisateur. |
| next |
Spécifie le nom du style à appliquer automatiquement à un nouveau paragraphe inséré après un paragraphe mis en forme avec le style. |
| no |
Spécifie s’il faut supprimer l’espacement entre les paragraphes mis en forme à l’aide du même style. |
| paragraph |
Obtient un |
| priority | Spécifie la priorité. |
| quick |
Spécifie si le style correspond à un style rapide disponible. |
| shading | Obtient un |
| table |
Obtient un |
| type | Obtient le type de style. |
| unhide |
Spécifie si le style est rendu visible en tant que style recommandé dans la galerie Styles et dans le volet Office Styles de Microsoft Word après son utilisation dans le document. |
| visibility | Spécifie si le style est visible en tant que style recommandé dans la galerie Styles et dans le volet Office Styles. |
Méthodes
| delete() | Supprime le style. |
| link |
Lie ce style à un modèle de liste afin que la mise en forme du style puisse être appliquée aux listes. |
| load(options) | Files d’attente de la commande pour charger les propriétés de l’objet spécifié. Vous devez contacter |
| load(property |
Files d’attente de la commande pour charger les propriétés de l’objet spécifié. Vous devez contacter |
| load(property |
Files d’attente de la commande pour charger les propriétés de l’objet spécifié. Vous devez contacter |
| set(properties, options) | Définit plusieurs propriétés d’un objet en même temps. Vous pouvez passer un objet brut avec les propriétés appropriées ou un autre objet API du même type. |
| set(properties) | Définit plusieurs propriétés sur l’objet en même temps, en fonction d’un objet chargé existant. |
| toJSON() | Remplace la méthode JavaScript |
| track() | Effectuer le suivi de l’objet pour l’ajustement automatique en fonction environnant des modifications dans le document. Cet appel est un raccourci pour context.trackedObjects.add(thisObject). Si vous utilisez cet objet sur des |
| untrack() | Publication mémoire associée à cet objet si elle a été précédemment suivie. Cet appel est abrégé pour context.trackedObjects.remove(thisObject). Vous rencontrez de nombreux objets suivies ralentit l’application hôte, donc n’oubliez pas de libérer les objets que l'on ajoute, une fois que vous avez terminé à les utiliser. Vous devez appeler |
Détails de la propriété
automaticallyUpdate
Spécifie si le style est automatiquement redéfini en fonction de la sélection.
automaticallyUpdate: boolean;
Valeur de propriété
boolean
Remarques
baseStyle
Spécifie le nom d’un style existant à utiliser comme mise en forme de base d’un autre style.
baseStyle: string;
Valeur de propriété
string
Remarques
[ Ensemble d’API : WordApi 1.5 ]
Remarque : La possibilité de définir baseStyle a été introduite dans WordApi 1.6.
borders
Spécifie un BorderCollection objet qui représente toutes les bordures du style.
readonly borders: Word.BorderCollection;
Valeur de propriété
Remarques
[ Ensemble d’API : WordApiDesktop 1.1 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Updates border properties (e.g., type, width, color) of the specified style.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to update border properties.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else {
const borders: Word.BorderCollection = style.borders;
borders.load("items");
await context.sync();
borders.outsideBorderType = Word.BorderType.dashed;
borders.outsideBorderWidth = Word.BorderWidth.pt025;
borders.outsideBorderColor = "green";
console.log("Updated outside borders.");
}
});
builtIn
Obtient si le style est un style intégré.
readonly builtIn: boolean;
Valeur de propriété
boolean
Remarques
context
Contexte de requête associé à l’objet . Cela connecte le processus du complément au processus de l’application hôte Office.
context: RequestContext;
Valeur de propriété
description
Notes
Cet API est fourni en tant qu’aperçu pour les développeurs et peut être modifié en fonction des commentaires que nous avons reçus. N’utilisez pas cet API dans un environnement de production.
Obtient la description du style.
readonly description: string;
Valeur de propriété
string
Remarques
font
Obtient un Font objet qui représente la mise en forme des caractères du style.
readonly font: Word.Font;
Valeur de propriété
Remarques
[ Ensemble d’API : WordApi 1.5 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Updates font properties (e.g., color, size) of the specified style.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to update font properties.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else {
const font: Word.Font = style.font;
font.color = "#FF0000";
font.size = 20;
console.log(`Successfully updated font properties of the '${styleName}' style.`);
}
});
frame
Renvoie un Frame objet qui représente la mise en forme du cadre pour le style.
readonly frame: Word.Frame;
Valeur de propriété
Remarques
hasProofing
Spécifie si le vérificateur d’orthographe et de grammaire ignore le texte mis en forme avec ce style.
hasProofing: boolean;
Valeur de propriété
boolean
Remarques
inUse
Indique si le style est un style intégré qui a été modifié ou appliqué dans le document ou un nouveau style qui a été créé dans le document.
readonly inUse: boolean;
Valeur de propriété
boolean
Remarques
languageId
Spécifie une LanguageId valeur qui représente la langue du style.
languageId: Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu";
Valeur de propriété
Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu"
Remarques
languageIdFarEast
Spécifie une langue d’Asie de l’Est pour le style.
languageIdFarEast: Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu";
Valeur de propriété
Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu"
Remarques
linked
Obtient si le style est un style lié qui peut être utilisé à la fois pour la mise en forme des paragraphes et des caractères.
readonly linked: boolean;
Valeur de propriété
boolean
Remarques
linkStyle
Spécifie un lien entre un paragraphe et un style de caractère.
linkStyle: Word.Style;
Valeur de propriété
Remarques
listLevelNumber
Retourne le niveau de liste pour le style.
readonly listLevelNumber: number;
Valeur de propriété
number
Remarques
listTemplate
Obtient un ListTemplate objet qui représente la mise en forme de liste pour le style.
readonly listTemplate: Word.ListTemplate;
Valeur de propriété
Remarques
[ Ensemble d’API : WordApiDesktop 1.1 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/20-lists/manage-list-styles.yaml
// Gets the properties of the specified style.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to get properties.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load("type");
await context.sync();
if (style.isNullObject || style.type != Word.StyleType.list) {
console.warn(`There's no existing style with the name '${styleName}'. Or this isn't a list style.`);
} else {
// Load objects to log properties and their values in the console.
style.load();
style.listTemplate.load();
await context.sync();
console.log(`Properties of the '${styleName}' style:`, style);
const listLevels = style.listTemplate.listLevels;
listLevels.load("items");
await context.sync();
console.log(`List levels of the '${styleName}' style:`, listLevels);
}
});
locked
Spécifie si le style ne peut pas être modifié ou modifié.
locked: boolean;
Valeur de propriété
boolean
Remarques
nameLocal
Obtient le nom du style dans la langue de l’utilisateur.
readonly nameLocal: string;
Valeur de propriété
string
Remarques
[ Ensemble d’API : WordApi 1.5 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Applies the specified style to a paragraph.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name-to-use") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to apply.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else if (style.type != Word.StyleType.paragraph) {
console.log(`The '${styleName}' style isn't a paragraph style.`);
} else {
const body: Word.Body = context.document.body;
body.clear();
body.insertParagraph(
"Do you want to create a solution that extends the functionality of Word? You can use the Office Add-ins platform to extend Word clients running on the web, on a Windows desktop, or on a Mac.",
"Start"
);
const paragraph: Word.Paragraph = body.paragraphs.getFirst();
paragraph.style = style.nameLocal;
console.log(`'${styleName}' style applied to first paragraph.`);
}
});
nextParagraphStyle
Spécifie le nom du style à appliquer automatiquement à un nouveau paragraphe inséré après un paragraphe mis en forme avec le style.
nextParagraphStyle: string;
Valeur de propriété
string
Remarques
[ Ensemble d’API : WordApi 1.5 ]
Remarque : La possibilité de définir nextParagraphStyle a été introduite dans WordApi 1.6.
noSpaceBetweenParagraphsOfSameStyle
Spécifie s’il faut supprimer l’espacement entre les paragraphes mis en forme à l’aide du même style.
noSpaceBetweenParagraphsOfSameStyle: boolean;
Valeur de propriété
boolean
Remarques
paragraphFormat
Obtient un ParagraphFormat objet qui représente les paramètres de paragraphe pour le style.
readonly paragraphFormat: Word.ParagraphFormat;
Valeur de propriété
Remarques
[ Ensemble d’API : WordApi 1.5 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Sets certain aspects of the specified style's paragraph format e.g., the left indent size and the alignment.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to update its paragraph format.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else {
style.paragraphFormat.leftIndent = 30;
style.paragraphFormat.alignment = Word.Alignment.centered;
console.log(`Successfully the paragraph format of the '${styleName}' style.`);
}
});
priority
Spécifie la priorité.
priority: number;
Valeur de propriété
number
Remarques
quickStyle
Spécifie si le style correspond à un style rapide disponible.
quickStyle: boolean;
Valeur de propriété
boolean
Remarques
shading
Obtient un Shading objet qui représente l’ombrage du style. Non applicable à un style de List type.
readonly shading: Word.Shading;
Valeur de propriété
Remarques
[ Ensemble d’API : WordApi 1.6 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Updates shading properties (e.g., texture, pattern colors) of the specified style.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to update shading properties.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else {
const shading: Word.Shading = style.shading;
shading.load();
await context.sync();
shading.backgroundPatternColor = "blue";
shading.foregroundPatternColor = "yellow";
shading.texture = Word.ShadingTextureType.darkTrellis;
console.log("Updated shading.");
}
});
tableStyle
Obtient un TableStyle objet représentant des propriétés de style qui peuvent être appliquées à une table.
readonly tableStyle: Word.TableStyle;
Valeur de propriété
Remarques
type
Obtient le type de style.
readonly type: Word.StyleType | "Character" | "List" | "Paragraph" | "Table";
Valeur de propriété
Word.StyleType | "Character" | "List" | "Paragraph" | "Table"
Remarques
unhideWhenUsed
Spécifie si le style est rendu visible en tant que style recommandé dans la galerie Styles et dans le volet Office Styles de Microsoft Word après son utilisation dans le document.
unhideWhenUsed: boolean;
Valeur de propriété
boolean
Remarques
visibility
Spécifie si le style est visible en tant que style recommandé dans la galerie Styles et dans le volet Office Styles.
visibility: boolean;
Valeur de propriété
boolean
Remarques
Détails de la méthode
delete()
Supprime le style.
delete(): void;
Retours
void
Remarques
[ Ensemble d’API : WordApi 1.5 ]
Exemples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/50-document/manage-styles.yaml
// Deletes the custom style.
await Word.run(async (context) => {
const styleName = (document.getElementById("style-name") as HTMLInputElement).value;
if (styleName == "") {
console.warn("Enter a style name to delete.");
return;
}
const style: Word.Style = context.document.getStyles().getByNameOrNullObject(styleName);
style.load();
await context.sync();
if (style.isNullObject) {
console.warn(`There's no existing style with the name '${styleName}'.`);
} else {
style.delete();
console.log(`Successfully deleted custom style '${styleName}'.`);
}
});
linkToListTemplate(listTemplate)
Lie ce style à un modèle de liste afin que la mise en forme du style puisse être appliquée aux listes.
linkToListTemplate(listTemplate: Word.ListTemplate): void;
Paramètres
- listTemplate
- Word.ListTemplate
ListTemplate à lier au style.
Retours
void
Remarques
load(options)
Files d’attente de la commande pour charger les propriétés de l’objet spécifié. Vous devez contacter context.sync() avant de lire les propriétés.
load(options?: Word.Interfaces.StyleLoadOptions): Word.Style;
Paramètres
- options
- Word.Interfaces.StyleLoadOptions
Fournit des options pour les propriétés de l’objet à charger.
Retours
load(propertyNames)
Files d’attente de la commande pour charger les propriétés de l’objet spécifié. Vous devez contacter context.sync() avant de lire les propriétés.
load(propertyNames?: string | string[]): Word.Style;
Paramètres
- propertyNames
-
string | string[]
Chaîne délimitée par des virgules ou tableau de chaînes qui spécifient les propriétés à charger.
Retours
load(propertyNamesAndPaths)
Files d’attente de la commande pour charger les propriétés de l’objet spécifié. Vous devez contacter context.sync() avant de lire les propriétés.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Word.Style;
Paramètres
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select est une chaîne délimitée par des virgules qui spécifie les propriétés à charger, et propertyNamesAndPaths.expand est une chaîne délimitée par des virgules qui spécifie les propriétés de navigation à charger.
Retours
set(properties, options)
Définit plusieurs propriétés d’un objet en même temps. Vous pouvez passer un objet brut avec les propriétés appropriées ou un autre objet API du même type.
set(properties: Interfaces.StyleUpdateData, options?: OfficeExtension.UpdateOptions): void;
Paramètres
- properties
- Word.Interfaces.StyleUpdateData
Objet JavaScript avec des propriétés qui sont structurées isomorphes en fonction des propriétés de l’objet sur lequel la méthode est appelée.
- options
- OfficeExtension.UpdateOptions
Fournit une option permettant de supprimer les erreurs si l’objet properties tente de définir des propriétés en lecture seule.
Retours
void
set(properties)
Définit plusieurs propriétés sur l’objet en même temps, en fonction d’un objet chargé existant.
set(properties: Word.Style): void;
Paramètres
- properties
- Word.Style
Retours
void
toJSON()
Remplace la méthode JavaScript toJSON() afin de fournir une sortie plus utile lorsqu’un objet API est passé à JSON.stringify(). (JSON.stringify, à son tour, appelle la toJSON méthode de l’objet qui lui est passé.) Alors que l’objet d’origine Word.Style est un objet API, la toJSON méthode renvoie un objet JavaScript brut (typé en tant Word.Interfaces.StyleDataque ) qui contient des copies superficielles de toutes les propriétés enfants chargées de l’objet d’origine.
toJSON(): Word.Interfaces.StyleData;
Retours
track()
Effectuer le suivi de l’objet pour l’ajustement automatique en fonction environnant des modifications dans le document. Cet appel est un raccourci pour context.trackedObjects.add(thisObject). Si vous utilisez cet objet sur des .sync appels et en dehors de l’exécution séquentielle d’un lot « .run », et que vous obtenez une erreur « InvalidObjectPath » lors de la définition d’une propriété ou de l’appel d’une méthode sur l’objet, vous devez ajouter l’objet à la collection d’objets suivie lors de la première création de l’objet. Si cet objet fait partie d’une collection, vous devez également suivre la collection parente.
track(): Word.Style;
Retours
untrack()
Publication mémoire associée à cet objet si elle a été précédemment suivie. Cet appel est abrégé pour context.trackedObjects.remove(thisObject). Vous rencontrez de nombreux objets suivies ralentit l’application hôte, donc n’oubliez pas de libérer les objets que l'on ajoute, une fois que vous avez terminé à les utiliser. Vous devez appeler context.sync() avant que la mise en production de la mémoire ne prenne effet.
untrack(): Word.Style;