The Fancypantsification of the Plain Vanilla Sheet
If you have data on a sheet that is stark and blah like so:
...and you prefer to give it a little pizazz, like so:
...all you need is the following few lines of code; all you might need to change in this code is the name of the worksheet (from "_xlWhateverSheet
"), and the name of the source table (from "tablifiedSheet
").
private Worksheet _xlWhateverSheet;
. . .
string tableStyleToUse = "TableStyleMedium9";
string nameOfSourceTable = "tablifiedSheet";
Range entireSheet = _xlWhateverSheet.UsedRange;
_xlWhateverSheet.ListObjects.Add(XlListObjectSourceType.xlSrcRange, entireSheet,
Type.Missing, XlYesNoGuess.xlYes, Type.Missing).Name = nameOfSourceTable;
_xlWhateverSheet.ListObjects[nameOfSourceTable].TableStyle = tableStyleToUse;
Note: You can change the table style to use, too (tableStyleToUse
) if you prefer something different than what is shown above. "TableStyleMedium9
" is the style used by default when you manually create a table in Excel; it is visually pleasing (YMMV) and provides a filter for each column.
I am in the process of morphing from a software developer into a portrayer of Mark Twain. My monologue (or one-man play, entitled "The Adventures of Mark Twain: As Told By Himself" and set in 1896) features Twain giving an overview of his life up till then. The performance includes the relating of interesting experiences and humorous anecdotes from Twain's boyhood and youth, his time as a riverboat pilot, his wild and woolly adventures in the Territory of Nevada and California, and experiences as a writer and world traveler, including recollections of meetings with many of the famous and powerful of the 19th century - royalty, business magnates, fellow authors, as well as intimate glimpses into his home life (his parents, siblings, wife, and children).
Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.
I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction, including a two-volume social and cultural history of the U.S. which covers important events from 1620-2006: http://www.lulu.com/spotlight/blackbirdcraven