Word.Style class
Representa um estilo em um documento do Word.
- Extends
Comentários
Usada por
- Word. Documento: addStyle
- Word. DocumentCreated: addStyle
- Word. StyleCollection: getByName, getByNameOrNullObject, getItem, items
Exemplos
// 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.`);
}
});
Propriedades
| automatically |
Especifica se o estilo é redefinido automaticamente com base na seleção. |
| base |
Especifica o nome de um estilo existente a ser usado como a formatação básica de outro estilo. |
| borders | Especifica um |
| built |
Determina se o estilo é interno. |
| context | O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office. |
| description | Obtém a descrição do estilo. |
| font | Obtém um |
| frame | Retorna um |
| has |
Especifica se o verificador ortográfico e gramatical ignora o texto formatado com esse estilo. |
| in |
Obtém se o estilo é um estilo interno que foi modificado ou aplicado no documento ou um novo estilo que foi criado no documento. |
| language |
Especifica um |
| language |
Especifica um idioma do Leste Asiático para o estilo. |
| linked | Obtém se o estilo é um estilo vinculado que pode ser usado para formatação de parágrafo e caractere. |
| link |
Especifica um vínculo entre um parágrafo e um estilo de caractere. |
| list |
Retorna o nível de lista para o estilo. |
| list |
Obtém um |
| locked | Especifica se o estilo não pode ser alterado ou editado. |
| name |
Obtém o nome do estilo no idioma do usuário. |
| next |
Especifica o nome do estilo a ser aplicado automaticamente a um novo parágrafo inserido após um parágrafo formatado com o estilo. |
| no |
Especifica se o espaçamento entre parágrafos formatados usando o mesmo estilo deve ser removido. |
| paragraph |
Obtém um |
| priority | Especifica a prioridade. |
| quick |
Especifica se o estilo corresponde a um estilo rápido disponível. |
| shading | Obtém um |
| table |
Obtém um objeto que representa propriedades de |
| type | Obtém o tipo de estilo. |
| unhide |
Especifica se o estilo se torna visível como um estilo recomendado na galeria Estilos e no painel de tarefas Estilos no Microsoft Word depois de ser usado no documento. |
| visibility | Especifica se o estilo é visível como um estilo recomendado na galeria Estilos e no painel de tarefas Estilos. |
Métodos
| delete() | Exclui o estilo. |
| link |
Vincula esse estilo a um modelo de lista para que a formatação do estilo possa ser aplicada a listas. |
| load(options) | Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar |
| load(property |
Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar |
| load(property |
Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar |
| set(properties, options) | Define várias propriedades de um objeto ao mesmo tempo. Você pode passar um objeto simples com as propriedades apropriadas ou outro objeto de API do mesmo tipo. |
| set(properties) | Define várias propriedades no objeto ao mesmo tempo, com base em um objeto carregado existente. |
| toJSON() | Substitui o método JavaScript |
| track() | Acompanha o objeto para ajuste automático com base nas alterações adjacentes no documento. Essa chamada é uma abreviação de context.trackedObjects.add(thisObject). Se você estiver usando esse objeto entre |
| untrack() | Libere a memória associada a este objeto, se ele já tiver sido rastreado anteriormente. Essa chamada é a forma abreviada de context.trackedObjects.remove(thisObject). Ter muitos objetos rastreados desacelera o aplicativo host, por isso, lembre-se de liberar todos os objetos adicionados após usá-los. Você precisará ligar |
Detalhes da propriedade
automaticallyUpdate
Especifica se o estilo é redefinido automaticamente com base na seleção.
automaticallyUpdate: boolean;
Valor da propriedade
boolean
Comentários
baseStyle
Especifica o nome de um estilo existente a ser usado como a formatação básica de outro estilo.
baseStyle: string;
Valor da propriedade
string
Comentários
Observação: a capacidade de definir baseStyle foi introduzida no WordApi 1.6.
borders
Especifica um BorderCollection objeto que representa todas as bordas do estilo.
readonly borders: Word.BorderCollection;
Valor da propriedade
Comentários
Conjunto de APIs: WordApiDesktop 1.1
Exemplos
// 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
Determina se o estilo é interno.
readonly builtIn: boolean;
Valor da propriedade
boolean
Comentários
context
O contexto de solicitação associado ao objeto. Isso conecta o processo do suplemento ao processo do aplicativo host do Office.
context: RequestContext;
Valor da propriedade
description
Observação
Esta API é fornecida como uma versão prévia para desenvolvedores e pode ser alterada com base nos comentários que recebemos. Não use esta API em um ambiente de produção.
Obtém a descrição do estilo.
readonly description: string;
Valor da propriedade
string
Comentários
font
Obtém um Font objeto que representa a formatação de caractere do estilo.
readonly font: Word.Font;
Valor da propriedade
Comentários
Exemplos
// 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
Retorna um Frame objeto que representa a formatação de quadro para o estilo.
readonly frame: Word.Frame;
Valor da propriedade
Comentários
hasProofing
Especifica se o verificador ortográfico e gramatical ignora o texto formatado com esse estilo.
hasProofing: boolean;
Valor da propriedade
boolean
Comentários
inUse
Obtém se o estilo é um estilo interno que foi modificado ou aplicado no documento ou um novo estilo que foi criado no documento.
readonly inUse: boolean;
Valor da propriedade
boolean
Comentários
languageId
Especifica um LanguageId valor que representa o idioma do estilo.
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";
Valor da propriedade
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"
Comentários
languageIdFarEast
Especifica um idioma do Leste Asiático para o estilo.
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";
Valor da propriedade
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"
Comentários
linked
Obtém se o estilo é um estilo vinculado que pode ser usado para formatação de parágrafo e caractere.
readonly linked: boolean;
Valor da propriedade
boolean
Comentários
linkStyle
Especifica um vínculo entre um parágrafo e um estilo de caractere.
linkStyle: Word.Style;
Valor da propriedade
Comentários
listLevelNumber
Retorna o nível de lista para o estilo.
readonly listLevelNumber: number;
Valor da propriedade
number
Comentários
listTemplate
Obtém um ListTemplate objeto que representa a formatação da lista para o estilo.
readonly listTemplate: Word.ListTemplate;
Valor da propriedade
Comentários
Conjunto de APIs: WordApiDesktop 1.1
Exemplos
// 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
Especifica se o estilo não pode ser alterado ou editado.
locked: boolean;
Valor da propriedade
boolean
Comentários
nameLocal
Obtém o nome do estilo no idioma do usuário.
readonly nameLocal: string;
Valor da propriedade
string
Comentários
Exemplos
// 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
Especifica o nome do estilo a ser aplicado automaticamente a um novo parágrafo inserido após um parágrafo formatado com o estilo.
nextParagraphStyle: string;
Valor da propriedade
string
Comentários
Observação: a capacidade de definir nextParagraphStyle foi introduzida no WordApi 1.6.
noSpaceBetweenParagraphsOfSameStyle
Especifica se o espaçamento entre parágrafos formatados usando o mesmo estilo deve ser removido.
noSpaceBetweenParagraphsOfSameStyle: boolean;
Valor da propriedade
boolean
Comentários
paragraphFormat
Obtém um ParagraphFormat objeto que representa as configurações de parágrafo para o estilo.
readonly paragraphFormat: Word.ParagraphFormat;
Valor da propriedade
Comentários
Exemplos
// 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
Especifica a prioridade.
priority: number;
Valor da propriedade
number
Comentários
quickStyle
Especifica se o estilo corresponde a um estilo rápido disponível.
quickStyle: boolean;
Valor da propriedade
boolean
Comentários
shading
Obtém um Shading objeto que representa o sombreamento do estilo. Não aplicável a um estilo de List tipo.
readonly shading: Word.Shading;
Valor da propriedade
Comentários
Exemplos
// 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
Obtém um objeto que representa propriedades de TableStyle estilo que podem ser aplicadas a uma tabela.
readonly tableStyle: Word.TableStyle;
Valor da propriedade
Comentários
type
Obtém o tipo de estilo.
readonly type: Word.StyleType | "Character" | "List" | "Paragraph" | "Table";
Valor da propriedade
Word.StyleType | "Character" | "List" | "Paragraph" | "Table"
Comentários
unhideWhenUsed
Especifica se o estilo se torna visível como um estilo recomendado na galeria Estilos e no painel de tarefas Estilos no Microsoft Word depois de ser usado no documento.
unhideWhenUsed: boolean;
Valor da propriedade
boolean
Comentários
visibility
Especifica se o estilo é visível como um estilo recomendado na galeria Estilos e no painel de tarefas Estilos.
visibility: boolean;
Valor da propriedade
boolean
Comentários
Detalhes do método
delete()
Exclui o estilo.
delete(): void;
Retornos
void
Comentários
Exemplos
// 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)
Vincula esse estilo a um modelo de lista para que a formatação do estilo possa ser aplicada a listas.
linkToListTemplate(listTemplate: Word.ListTemplate): void;
Parâmetros
- listTemplate
- Word.ListTemplate
A ListTemplate para vincular ao estilo.
Retornos
void
Comentários
load(options)
Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.
load(options?: Word.Interfaces.StyleLoadOptions): Word.Style;
Parâmetros
- options
- Word.Interfaces.StyleLoadOptions
Fornece opções para quais propriedades do objeto devem ser carregadas.
Retornos
load(propertyNames)
Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.
load(propertyNames?: string | string[]): Word.Style;
Parâmetros
- propertyNames
-
string | string[]
Uma cadeia de caracteres delimitada por vírgula ou uma matriz de cadeias de caracteres que especifica as propriedades a serem carregadas.
Retornos
load(propertyNamesAndPaths)
Coloca um comando na fila para carregar as propriedades especificadas do objeto. Você deve chamar context.sync() antes de ler as propriedades.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Word.Style;
Parâmetros
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select é uma cadeia de caracteres delimitada por vírgula que especifica as propriedades a serem carregadas e propertyNamesAndPaths.expand é uma cadeia de caracteres delimitada por vírgula que especifica as propriedades de navegação a serem carregadas.
Retornos
set(properties, options)
Define várias propriedades de um objeto ao mesmo tempo. Você pode passar um objeto simples com as propriedades apropriadas ou outro objeto de API do mesmo tipo.
set(properties: Interfaces.StyleUpdateData, options?: OfficeExtension.UpdateOptions): void;
Parâmetros
- properties
- Word.Interfaces.StyleUpdateData
Um objeto JavaScript com propriedades estruturadas isomorficamente para as propriedades do objeto no qual o método é chamado.
- options
- OfficeExtension.UpdateOptions
Fornece uma opção para suprimir erros se o objeto de propriedades tentar definir propriedades somente leitura.
Retornos
void
set(properties)
Define várias propriedades no objeto ao mesmo tempo, com base em um objeto carregado existente.
set(properties: Word.Style): void;
Parâmetros
- properties
- Word.Style
Retornos
void
toJSON()
Substitui o método JavaScript toJSON() para fornecer uma saída mais útil quando um objeto de API é passado para JSON.stringify(). (JSON.stringify, por sua vez, chama o toJSON método do objeto que é passado para ele.) Enquanto o objeto original Word.Style é um objeto de API, o toJSON método retorna um objeto JavaScript simples (digitado como Word.Interfaces.StyleData) que contém cópias superficiais de todas as propriedades filho carregadas do objeto original.
toJSON(): Word.Interfaces.StyleData;
Retornos
track()
Acompanha o objeto para ajuste automático com base nas alterações adjacentes no documento. Essa chamada é uma abreviação de context.trackedObjects.add(thisObject). Se você estiver usando esse objeto entre .sync chamadas e fora da execução sequencial de um lote ".run" e receber um erro "InvalidObjectPath" ao definir uma propriedade ou invocar um método no objeto, precisará adicionar o objeto à coleção de objetos rastreados quando o objeto foi criado pela primeira vez. Se esse objeto fizer parte de uma coleção, você também deverá acompanhar a coleção pai.
track(): Word.Style;
Retornos
untrack()
Libere a memória associada a este objeto, se ele já tiver sido rastreado anteriormente. Essa chamada é a forma abreviada de context.trackedObjects.remove(thisObject). Ter muitos objetos rastreados desacelera o aplicativo host, por isso, lembre-se de liberar todos os objetos adicionados após usá-los. Você precisará ligar context.sync() antes que a liberação de memória entre em vigor.
untrack(): Word.Style;