Click here to Skip to main content
16,006,535 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Converting from a byte array to a string? Pin
Nick The Newbie26-Jul-06 10:59
Nick The Newbie26-Jul-06 10:59 
AnswerRe: Converting from a byte array to a string? Pin
Guffa26-Jul-06 11:06
Guffa26-Jul-06 11:06 
GeneralRe: Converting from a byte array to a string? [modified] Pin
Nick The Newbie26-Jul-06 11:13
Nick The Newbie26-Jul-06 11:13 
QuestionQuerying Users in AD and displaying them in a Combo Box Pin
Parry1126-Jul-06 9:31
Parry1126-Jul-06 9:31 
AnswerRe: Querying Users in AD and displaying them in a Combo Box Pin
Joshua Boyle26-Jul-06 9:51
Joshua Boyle26-Jul-06 9:51 
GeneralRe: Querying Users in AD and displaying them in a Combo Box Pin
Parry1126-Jul-06 10:25
Parry1126-Jul-06 10:25 
QuestionExport DataGridView to MS Word Pin
jrewen26-Jul-06 8:46
jrewen26-Jul-06 8:46 
AnswerRe: Export DataGridView to MS Word Pin
jrewen26-Jul-06 11:13
jrewen26-Jul-06 11:13 
[Thank you, Joshua -->

reply:
Hello, James!

I was able to find some code to do precisely that here on codeproject. The code to do so is as follows:


Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.word";

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

myDataGrid.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();


The URL actually has code for exporting to Excel, Word and Text files and can be reached via the following link:

http://www.codeproject.com/aspnet/DAtaGridExportToExcel.asp[^]
/]

May I ask for a little more help though (d'oh! D'Oh! | :doh: ). My dgvs are on a windows form (VS.2005) - and I'm not quite sure if these objects are viable in this environment (i.e. - the HttpTextWriter is not found in System.Web)

so, looking away from the syntax of this, functionally what is happening is that each line of data from my datagridview is being sent to the writer - which then inserts it into the word doc, correct? If so, this shouldn't include formatting, colors, etc. - correct?

looks like i should be able to do this by pushing it line by line into excel and formatting there - and then automating a cut and paste operation into word - but that's a little excessive! WTF | :WTF:


ideas? (thanks again for the help)

Questionme.Close() vs me.Dispose() Pin
Oneiroid26-Jul-06 8:09
Oneiroid26-Jul-06 8:09 
AnswerRe: me.Close() vs me.Dispose() Pin
mAreValo26-Jul-06 8:21
mAreValo26-Jul-06 8:21 
GeneralRe: me.Close() vs me.Dispose() Pin
Oneiroid26-Jul-06 13:40
Oneiroid26-Jul-06 13:40 
QuestionTS admin program need some help please Pin
Aaron12826-Jul-06 7:18
Aaron12826-Jul-06 7:18 
GeneralRe: TS admin program need some help please Pin
Aaron12826-Jul-06 8:32
Aaron12826-Jul-06 8:32 
QuestionHELP!!! LINKED LISTS!!! [modified] Pin
snowwhite198526-Jul-06 7:06
snowwhite198526-Jul-06 7:06 
AnswerRe: HELP!!! LINKED LISTS!!! Pin
Paul Conrad26-Jul-06 9:37
professionalPaul Conrad26-Jul-06 9:37 
QuestionMenuStrip Question Pin
swcrissman26-Jul-06 6:46
swcrissman26-Jul-06 6:46 
QuestionIs there a way to hide datagrid columns Pin
nImStucked26-Jul-06 6:33
nImStucked26-Jul-06 6:33 
GeneralRe: Is there a way to hide datagrid columns Pin
BrazenSix26-Jul-06 6:37
BrazenSix26-Jul-06 6:37 
AnswerRe: Is there a way to hide datagrid columns [modified] Pin
Nouvand3-Aug-06 23:33
Nouvand3-Aug-06 23:33 
QuestionAbout User Entered Data [modified] Pin
BrazenSix26-Jul-06 6:32
BrazenSix26-Jul-06 6:32 
AnswerRe: About User Entered Data [modified] Pin
Aaron12826-Jul-06 7:13
Aaron12826-Jul-06 7:13 
GeneralRe: About User Entered Data Pin
BrazenSix26-Jul-06 8:08
BrazenSix26-Jul-06 8:08 
AnswerRe: About User Entered Data Pin
BrazenSix26-Jul-06 10:39
BrazenSix26-Jul-06 10:39 
GeneralRe: About User Entered Data [modified] Pin
Aaron12826-Jul-06 11:14
Aaron12826-Jul-06 11:14 
AnswerRe: About User Entered Data Pin
Nouvand3-Aug-06 23:46
Nouvand3-Aug-06 23:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.