Click here to Skip to main content
15,902,842 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to write on an html page through StremWriter class?? Pin
Guffa22-Jan-07 22:24
Guffa22-Jan-07 22:24 
GeneralRe: how to write on an html page through StremWriter class?? Pin
bobsugar22222-Jan-07 22:35
bobsugar22222-Jan-07 22:35 
AnswerRe: how to write on an html page through StremWriter class?? Pin
Stefan Troschuetz22-Jan-07 22:23
Stefan Troschuetz22-Jan-07 22:23 
GeneralRe: how to write on an html page through StremWriter class?? Pin
Saira Tanwir22-Jan-07 22:33
Saira Tanwir22-Jan-07 22:33 
GeneralRe: how to write on an html page through StremWriter class?? [modified] Pin
bobsugar22222-Jan-07 22:39
bobsugar22222-Jan-07 22:39 
GeneralRe: how to write on an html page through StremWriter class?? Pin
Saira Tanwir22-Jan-07 22:51
Saira Tanwir22-Jan-07 22:51 
GeneralRe: how to write on an html page through StremWriter class?? Pin
bobsugar22222-Jan-07 22:59
bobsugar22222-Jan-07 22:59 
GeneralRe: how to write on an html page through StremWriter class?? Pin
bobsugar22223-Jan-07 0:09
bobsugar22223-Jan-07 0:09 
ok here we go. I created a win form an in the Load event I've added this code:

private void Form1_Load(object sender, EventArgs e)
{
// Create a sample DataSet
DataSet dataSet = new DataSet("myDataSet");
DataTable dataTable = new DataTable("myTable");
dataSet.Tables.Add(dataTable);
DataColumn column = new DataColumn("firstName");
dataTable.Columns.Add(column);
column = new DataColumn("lastName");
dataTable.Columns.Add(column);
column = new DataColumn("phone");
dataTable.Columns.Add(column);

// Add some sample data
DataRow row = dataTable.NewRow();
row["firstName"] = "Joe";
row["lastName"] = "Public";
row["phone"] = "0123456789";
dataTable.Rows.Add(row);

row = dataTable.NewRow();
row["firstName"] = "Bob";
row["lastName"] = "Sugar";
row["phone"] = "9876543210";
dataTable.Rows.Add(row);

// Convert dataset to an XmlDocument (XmlDataDocument in this case
// so we can pass it the dataSet directly instead of faffing
// about with MemoryStreams / XmlWriters
XmlDataDocument xmlDataDoc = new XmlDataDocument(dataSet);
// set constraints so that we can work with the dataSet as XmlDocument
xmlDataDoc.DataSet.EnforceConstraints = false;

// Link our CSS file to the xml document by inserting a processing
// instruction
XmlProcessingInstruction p = xmlDataDoc.CreateProcessingInstruction("xml-stylesheet", "href=\"myReport.css\" type=\"text/css\"");
xmlDataDoc.InsertBefore(p, xmlDataDoc.ChildNodes[0]);

// Save the xml file
xmlDataDoc.Save("myReport2.xml");
}

I've also created this very simple css file, called it "myReport.css" and dumped it in the project debug folder:

myTable {
display: list-item;
}

firstName {
color: #0000ff;
font-family: Arial;
font-size: 10pt;
}

lastName {
color: #ff0000;
font-family: "Times New Roman";
font-size: 11pt;
}

phone {
color: #00ff00;
font-family: "Courier New";
font-size: 12pt;
}

Run that up then open the xml file, it should automatically reference the css file and do the formatting for you.
GeneralRe: how to write on an html page through StremWriter class?? Pin
Stefan Troschuetz22-Jan-07 22:48
Stefan Troschuetz22-Jan-07 22:48 
GeneralRe: how to write on an html page through StremWriter class?? Pin
Saira Tanwir22-Jan-07 22:59
Saira Tanwir22-Jan-07 22:59 
QuestionList of languages in C# Pin
bouli22-Jan-07 20:35
bouli22-Jan-07 20:35 
AnswerRe: List of languages in C# Pin
lmoelleb22-Jan-07 20:41
lmoelleb22-Jan-07 20:41 
QuestionSort DatagridView Pin
aaraaayen22-Jan-07 18:55
aaraaayen22-Jan-07 18:55 
AnswerRe: Sort DatagridView Pin
Guffa22-Jan-07 19:25
Guffa22-Jan-07 19:25 
GeneralRe: Sort DatagridView Pin
aaraaayen22-Jan-07 19:45
aaraaayen22-Jan-07 19:45 
AnswerRe: Sort DatagridView Pin
Guffa22-Jan-07 21:09
Guffa22-Jan-07 21:09 
QuestionStore value in application instead of database Pin
cocoonwls22-Jan-07 18:04
cocoonwls22-Jan-07 18:04 
AnswerRe: Store value in application instead of database Pin
Parwej Ahamad22-Jan-07 18:21
professionalParwej Ahamad22-Jan-07 18:21 
AnswerRe: Store value in application instead of database Pin
Christian Graus22-Jan-07 18:59
protectorChristian Graus22-Jan-07 18:59 
GeneralRe: Store value in application instead of database Pin
cocoonwls22-Jan-07 19:23
cocoonwls22-Jan-07 19:23 
GeneralRe: Store value in application instead of database Pin
Christian Graus22-Jan-07 19:43
protectorChristian Graus22-Jan-07 19:43 
GeneralRe: Store value in application instead of database Pin
cocoonwls22-Jan-07 20:00
cocoonwls22-Jan-07 20:00 
GeneralRe: Store value in application instead of database Pin
Christian Graus22-Jan-07 20:03
protectorChristian Graus22-Jan-07 20:03 
GeneralRe: Store value in application instead of database [modified] Pin
bobsugar22222-Jan-07 22:09
bobsugar22222-Jan-07 22:09 
AnswerRe: Store value in application instead of database Pin
aSarafian23-Jan-07 1:05
aSarafian23-Jan-07 1:05 

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.