I have a spreadshhet I just created, I get a WorksheetRegion and use the FormatAsTable method. I now have a table that uses the default Excel style. I want to be able to have no style on this table. This would be the equivalent of using the COM command below
ActiveSheet.ListObjects("Table1").TableStyle = ""
Nothing I've tried removes the style or allows me to add a table with no style. I can change the style fine, removing is the problem.
Any ideas?
Thanks,
Tom
Hello Tom,
The DefaultTableStyle is set to TableStyleMedium2 which is from my understanding what you wish to change or remove. Keep in mind passing null as the second paramter when calling FormatAsTable will set this table style.
Our online documentation explains this and more about setting any WorkSheetTableStyle in the CustomTableStyles or StandardTableStyles collection.
http://help.infragistics.com/doc/WinForms/2014.2/CLR4.0/?page=Infragistics4.Documents.Excel.v14.2~Infragistics.Documents.Excel.Workbook~DefaultTableStyle.html
Excel doesn't have any blank table styles that I am aware of. Let me know if you have any questions regardingt this matter.
Everything you say is correct, yet I still don't know how to have a table with no style. In. Excel, it's easy to select, in the style selector, a style labelled None. Doing this results in the VBA code I posted.
i would like to be able to get this result using Infragistics.
You can create your own custom style and add it to the workbook's CustomTableStyles collection. This way when you pass your custom style as the second parameter for FormatAsTable and the default style won't be used. The cells will appear as normal but with an empty custom style applied. You can always modifiy your table later or we also have 60 standard styles from which you can choose from as well.
Here is an example of exporting the grid to excel, but beforehand I override the worksheet and define my new custom region and table.
void ultraGridExcelExporter1_ExportStarted(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.ExportStartedEventArgs e) { Infragistics.Documents.Excel.WorksheetRegion region = new Infragistics.Documents.Excel.WorksheetRegion(e.CurrentWorksheet, 0, 0, 5, 0); WorksheetTableStyle tableStyle = new WorksheetTableStyle("customTableStyle"); e.Workbook.CustomTableStyles.Add(tableStyle); var customStyle = e.Workbook.CustomTableStyles[0]; Infragistics.Documents.Excel.WorksheetTable table = region.FormatAsTable(true, customStyle);
}
I recommend submitting a feature request on our website <ideas.infragistics.com> so that the leaving the second parameter for FormatTableString empty will not use the default style.
Let me know if you have any quesitons regarding this matter.
Hi,
This works and is almost exactly the same as having no style. The only difference to anyone using the spreadsheet is the style selector shows both this style, and the one that it labels "None".
The tooltip shown is pulled from the string you assigned for your WorkSheetTableStyle. Since excel demands a name you can set the tableStyle.Name property to open quotes " " if you don't want text shown in the tooltip.
When using Excel (2013 in my case), when you have a table, and the cursor is in one of the table cells, there's a "Design" tab on the Ribbon. If you click on the design tab, you'll have a "Table Styles" section on the ribbon. This sections shows a few styles, the exact number depends upon the size of your window. If you choose the drop down button, a panel opens showing a large number of styles. They are divided into Light, Medium, and Dark. Each of the Table style images has a tooltip with the name of the style. In the upper left is a "Style" with the tooltip value of "None".
I am glad my recommendation worked for you, but can you please clarify what you mean by the selelctor and labels?
If you have any additional quesitons please do not hestate to ask.