We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Creating a workbook using a pre-made template - Styles

Thread ID:

Created:

Updated:

Platform:

Replies:

24571 Feb 7,2005 01:45 PM Feb 9,2005 09:40 AM Windows Forms 1
loading
Tags: XlsIO
Shannon Broskie
Asked On February 7, 2005 01:45 PM

Hello, I''m having an issue where we create an IWorkbook from a template (xlt) using the following code: ----- public static IWorkbook CreateNewWorkbook() { RegistryKey key = Registry.CurrentUser.OpenSubKey( @"SOFTWARE\TAG" ); string reportTemplate = key.GetValue( "Report Template" ).ToString(); return CreateNewWorkbook( reportTemplate ); } .... IWorksheet sheet = workBook.Worksheets[ 0 ]; sheet.Range[ 1, 1, 1, 5 ].Text = "Column"; sheet.Range[ 1, 1, 1, 5 ].CellStyleName = "ColumnHeader"; ----- This template has pre-made styles in it. My issue is that if that style is not actively used in a cell when the template is loaded, the following error occurs when trying to assign that pre-made style to a cell. "Style with specified name does not exists. Name: ColumnHeader". If I assign cell A1 the style ColumnHeader inside the template file and then do this, all is well. It seems that when the IWorkbook is created, it only loads those styles that are actively being used. I tried to attach the Excel template but it seems the file attachment form is not working. I will be more than happy to email the template if an address is provided. Any comments would be appreciated. Thanks!

Administrator [Syncfusion]
Replied On February 9, 2005 09:40 AM

Hi Shannon, Please send the file to stephenj @ syncfusion.com Thanks, Stephen. >Hello, I''m having an issue where we create an IWorkbook from a template (xlt) using the following code: >----- > public static IWorkbook CreateNewWorkbook() > { > RegistryKey key = Registry.CurrentUser.OpenSubKey( @"SOFTWARE\TAG" ); > > string reportTemplate = key.GetValue( "Report Template" ).ToString(); > > return CreateNewWorkbook( reportTemplate ); > } >.... > > IWorksheet sheet = workBook.Worksheets[ 0 ]; > sheet.Range[ 1, 1, 1, 5 ].Text = "Column"; > sheet.Range[ 1, 1, 1, 5 ].CellStyleName = "ColumnHeader"; > >----- >This template has pre-made styles in it. My issue is that if that style is not actively used in a cell when the template is loaded, the following error occurs when trying to assign that pre-made style to a cell. "Style with specified name does not exists. Name: ColumnHeader". > >If I assign cell A1 the style ColumnHeader inside the template file and then do this, all is well. It seems that when the IWorkbook is created, it only loads those styles that are actively being used. > >I tried to attach the Excel template but it seems the file attachment form is not working. I will be more than happy to email the template if an address is provided. > >Any comments would be appreciated. >Thanks! >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;