Word.Style class
Representa un estilo en un documento de Word.
- Extends
Comentarios
Usada por
- Word. Documento: addStyle
- Word. DocumentCreated: addStyle
- Word. StyleCollection: getByName, getByNameOrNullObject, getItem, items
Ejemplos
// 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.`);
}
});
Propiedades
| automatically |
Especifica si el estilo se redefine automáticamente en función de la selección. |
| base |
Especifica el nombre de un estilo existente que se va a usar como formato base de otro estilo. |
| borders | Especifica un |
| built |
Obtiene si el estilo es un estilo integrado. |
| context | El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office. |
| description | Obtiene la descripción del estilo. |
| font | Obtiene un |
| frame | Devuelve un |
| has |
Especifica si el corrector ortográfico y gramatical omite el texto con formato con este estilo. |
| in |
Obtiene si el estilo es un estilo integrado que se ha modificado o aplicado en el documento o un nuevo estilo que se ha creado en el documento. |
| language |
Especifica un |
| language |
Especifica un idioma de Asia Oriental para el estilo. |
| linked | Obtiene si el estilo es un estilo vinculado que se puede usar tanto para formato de párrafo como de caracteres. |
| link |
Especifica un vínculo entre un párrafo y un estilo de carácter. |
| list |
Devuelve el nivel de lista del estilo. |
| list |
Obtiene un |
| locked | Especifica si el estilo no se puede cambiar o editar. |
| name |
Obtiene el nombre del estilo en el idioma del usuario. |
| next |
Especifica el nombre del estilo que se aplicará automáticamente a un nuevo párrafo que se inserta después de un párrafo con el formato del estilo. |
| no |
Especifica si se quita el espaciado entre párrafos con el mismo estilo. |
| paragraph |
Obtiene un |
| priority | Especifica la prioridad. |
| quick |
Especifica si el estilo corresponde a un estilo rápido disponible. |
| shading | Obtiene un |
| table |
Obtiene un objeto que representa las |
| type | Obtiene el tipo de estilo. |
| unhide |
Especifica si el estilo se hace visible como estilo recomendado en la galería Estilos y en el panel de tareas Estilos de Microsoft Word después de usarlo en el documento. |
| visibility | Especifica si el estilo está visible como estilo recomendado en la galería Estilos y en el panel de tareas Estilos. |
Métodos
| delete() | Elimina el estilo. |
| link |
Vincula este estilo a una plantilla de lista para que el formato del estilo se pueda aplicar a las listas. |
| load(options) | Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| load(property |
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| load(property |
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a |
| set(properties, options) | Establece varias propiedades de un objeto al mismo tiempo. Puede pasar un objeto sin formato con las propiedades adecuadas u otro objeto API del mismo tipo. |
| set(properties) | Establece varias propiedades en el objeto al mismo tiempo, basadas en un objeto cargado existente. |
| toJSON() | Reemplaza el método JavaScript |
| track() | Realiza un seguimiento del objeto de ajuste automático según cambios adyacentes en el documento. Esta llamada es una abreviatura de context.trackedObjects.add(thisObject). Si usa este objeto entre |
| untrack() | Libere la memoria asociada a este objeto, si se ha realizado un seguimiento de él anteriormente. Esta llamada es la abreviatura de context.trackedObjects.remove(thisObject). Tener muchos objetos marcados ralentiza la aplicación host, así que debe recordar liberar los objetos que agregue cuando haya terminado con ellos. Deberá llamar |
Detalles de las propiedades
automaticallyUpdate
Especifica si el estilo se redefine automáticamente en función de la selección.
automaticallyUpdate: boolean;
Valor de propiedad
boolean
Comentarios
baseStyle
Especifica el nombre de un estilo existente que se va a usar como formato base de otro estilo.
baseStyle: string;
Valor de propiedad
string
Comentarios
Nota: La capacidad de establecer baseStyle se introdujo en WordApi 1.6.
borders
Especifica un BorderCollection objeto que representa todos los bordes del estilo.
readonly borders: Word.BorderCollection;
Valor de propiedad
Comentarios
Conjunto de API: WordApiDesktop 1.1
Ejemplos
// 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
Obtiene si el estilo es un estilo integrado.
readonly builtIn: boolean;
Valor de propiedad
boolean
Comentarios
context
El contexto de solicitud asociado al objeto. De esta forma, se conecta el proceso del complemento con el proceso de la aplicación host de Office.
context: RequestContext;
Valor de propiedad
description
Nota
Esta API se ofrece a los desarrolladores como versión preliminar y puede cambiar en función de los comentarios que recibamos. No utilice esta API en un entorno de producción.
Obtiene la descripción del estilo.
readonly description: string;
Valor de propiedad
string
Comentarios
font
Obtiene un Font objeto que representa el formato de caracteres del estilo.
readonly font: Word.Font;
Valor de propiedad
Comentarios
Ejemplos
// 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
Devuelve un Frame objeto que representa el formato de marco del estilo.
readonly frame: Word.Frame;
Valor de propiedad
Comentarios
hasProofing
Especifica si el corrector ortográfico y gramatical omite el texto con formato con este estilo.
hasProofing: boolean;
Valor de propiedad
boolean
Comentarios
inUse
Obtiene si el estilo es un estilo integrado que se ha modificado o aplicado en el documento o un nuevo estilo que se ha creado en el documento.
readonly inUse: boolean;
Valor de propiedad
boolean
Comentarios
languageId
Especifica un LanguageId valor que representa el idioma del 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 de propiedad
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"
Comentarios
languageIdFarEast
Especifica un idioma de Asia Oriental para el 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 de propiedad
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"
Comentarios
linked
Obtiene si el estilo es un estilo vinculado que se puede usar tanto para formato de párrafo como de caracteres.
readonly linked: boolean;
Valor de propiedad
boolean
Comentarios
linkStyle
Especifica un vínculo entre un párrafo y un estilo de carácter.
linkStyle: Word.Style;
Valor de propiedad
Comentarios
listLevelNumber
Devuelve el nivel de lista del estilo.
readonly listLevelNumber: number;
Valor de propiedad
number
Comentarios
listTemplate
Obtiene un ListTemplate objeto que representa el formato de lista para el estilo.
readonly listTemplate: Word.ListTemplate;
Valor de propiedad
Comentarios
Conjunto de API: WordApiDesktop 1.1
Ejemplos
// 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 si el estilo no se puede cambiar o editar.
locked: boolean;
Valor de propiedad
boolean
Comentarios
nameLocal
Obtiene el nombre del estilo en el idioma del usuario.
readonly nameLocal: string;
Valor de propiedad
string
Comentarios
Ejemplos
// 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 el nombre del estilo que se aplicará automáticamente a un nuevo párrafo que se inserta después de un párrafo con el formato del estilo.
nextParagraphStyle: string;
Valor de propiedad
string
Comentarios
Nota: La capacidad de establecer nextParagraphStyle se introdujo en WordApi 1.6.
noSpaceBetweenParagraphsOfSameStyle
Especifica si se quita el espaciado entre párrafos con el mismo estilo.
noSpaceBetweenParagraphsOfSameStyle: boolean;
Valor de propiedad
boolean
Comentarios
paragraphFormat
Obtiene un ParagraphFormat objeto que representa la configuración de párrafo del estilo.
readonly paragraphFormat: Word.ParagraphFormat;
Valor de propiedad
Comentarios
Ejemplos
// 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 la prioridad.
priority: number;
Valor de propiedad
number
Comentarios
quickStyle
Especifica si el estilo corresponde a un estilo rápido disponible.
quickStyle: boolean;
Valor de propiedad
boolean
Comentarios
shading
Obtiene un Shading objeto que representa el sombreado del estilo. No se aplica a un estilo de List tipo.
readonly shading: Word.Shading;
Valor de propiedad
Comentarios
Ejemplos
// 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
Obtiene un objeto que representa las TableStyle propiedades de estilo que se pueden aplicar a una tabla.
readonly tableStyle: Word.TableStyle;
Valor de propiedad
Comentarios
type
Obtiene el tipo de estilo.
readonly type: Word.StyleType | "Character" | "List" | "Paragraph" | "Table";
Valor de propiedad
Word.StyleType | "Character" | "List" | "Paragraph" | "Table"
Comentarios
unhideWhenUsed
Especifica si el estilo se hace visible como estilo recomendado en la galería Estilos y en el panel de tareas Estilos de Microsoft Word después de usarlo en el documento.
unhideWhenUsed: boolean;
Valor de propiedad
boolean
Comentarios
visibility
Especifica si el estilo está visible como estilo recomendado en la galería Estilos y en el panel de tareas Estilos.
visibility: boolean;
Valor de propiedad
boolean
Comentarios
Detalles del método
delete()
Elimina el estilo.
delete(): void;
Devoluciones
void
Comentarios
Ejemplos
// 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 este estilo a una plantilla de lista para que el formato del estilo se pueda aplicar a las listas.
linkToListTemplate(listTemplate: Word.ListTemplate): void;
Parámetros
- listTemplate
- Word.ListTemplate
A ListTemplate para vincular al estilo.
Devoluciones
void
Comentarios
load(options)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(options?: Word.Interfaces.StyleLoadOptions): Word.Style;
Parámetros
- options
- Word.Interfaces.StyleLoadOptions
Proporciona opciones para las propiedades del objeto que se van a cargar.
Devoluciones
load(propertyNames)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(propertyNames?: string | string[]): Word.Style;
Parámetros
- propertyNames
-
string | string[]
Una cadena delimitada por comas o una matriz de cadenas que especifican las propiedades que se van a cargar.
Devoluciones
load(propertyNamesAndPaths)
Pone en cola un comando para cargar las propiedades especificadas del objeto. Debe llamar a context.sync() antes de leer las propiedades.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Word.Style;
Parámetros
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select es una cadena delimitada por comas que especifica las propiedades que se van a cargar y propertyNamesAndPaths.expand es una cadena delimitada por comas que especifica las propiedades de navegación que se van a cargar.
Devoluciones
set(properties, options)
Establece varias propiedades de un objeto al mismo tiempo. Puede pasar un objeto sin formato con las propiedades adecuadas u otro objeto API del mismo tipo.
set(properties: Interfaces.StyleUpdateData, options?: OfficeExtension.UpdateOptions): void;
Parámetros
- properties
- Word.Interfaces.StyleUpdateData
Un objeto JavaScript con propiedades que están estructuradas isomorfamente a las propiedades del objeto en el que se llama al método.
- options
- OfficeExtension.UpdateOptions
Proporciona una opción para suprimir errores si el objeto properties intenta establecer propiedades de solo lectura.
Devoluciones
void
set(properties)
Establece varias propiedades en el objeto al mismo tiempo, basadas en un objeto cargado existente.
set(properties: Word.Style): void;
Parámetros
- properties
- Word.Style
Devoluciones
void
toJSON()
Reemplaza el método JavaScript toJSON() para proporcionar una salida más útil cuando se pasa un objeto API a JSON.stringify(). (JSON.stringify, a su vez, llama al toJSON método del objeto que se le pasa). Mientras que el objeto original Word.Style es un objeto API, el toJSON método devuelve un objeto JavaScript simple (escrito como Word.Interfaces.StyleData) que contiene copias superficiales de cualquier propiedad secundaria cargada del objeto original.
toJSON(): Word.Interfaces.StyleData;
Devoluciones
track()
Realiza un seguimiento del objeto de ajuste automático según cambios adyacentes en el documento. Esta llamada es una abreviatura de context.trackedObjects.add(thisObject). Si usa este objeto entre .sync llamadas y fuera de la ejecución secuencial de un lote ".run" y recibe un error "InvalidObjectPath" al establecer una propiedad o invocar un método en el objeto, debe agregar el objeto a la colección de objetos objeto de seguimiento cuando se creó el objeto por primera vez. Si este objeto forma parte de una colección, también debe realizar un seguimiento de la colección primaria.
track(): Word.Style;
Devoluciones
untrack()
Libere la memoria asociada a este objeto, si se ha realizado un seguimiento de él anteriormente. Esta llamada es la abreviatura de context.trackedObjects.remove(thisObject). Tener muchos objetos marcados ralentiza la aplicación host, así que debe recordar liberar los objetos que agregue cuando haya terminado con ellos. Deberá llamar context.sync() antes de que la liberación de memoria surta efecto.
untrack(): Word.Style;