|
As i'm trying to create my own Report, i thought i could create a blank html page in my project and use it to create different html based reports and i want to use the StreamWriter class.
is it the right approach to create the report or should i rather use Xml instead cause i have to create the report and display the record of a table in the database.
|
|
|
|
|
I think you may be better off using true xml as output and use css for formatting to the end-user. Then all you would do is create css files for all your report types and all you would need to worry about in-code would be outputting the 'real' data to xml.
If you have your data in a DataSet and you can make your CSS fit then it may even be as simple as Serialization eg.
myDataSet.WriteXml(filepath);
Job done.
-- modified at 4:45 Tuesday 23rd January, 2007
|
|
|
|
|
can u suggest any startups on that??
regards
Saira
|
|
|
|
|
|
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.
|
|
|
|
|
There's nothing wrong with using the StreamWriter to create the html report, but it may be easier with the XmlTextWriter as it is specialized on the generation of xml files and html can be regarded as a special xml grammar. As said before it frees you from generating the markup and thereby will ease your work and make it less error prone. By the way, it is not that different from the StreamWriter. Simply spoken, it only provides some more specialized Write methods. Take a look at the examples in the documentation and I'm sure you get used to it quickly.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
thanks guys
until the next problem....
Regards
Saira
|
|
|
|
|
Hello gurus,
I'd like to know if there is a class that retrieves the list of all primary languages (English, French, Spanish...) and there standard codes (0x0409 etc.)
I think there is a way to get these languages and their associated standard codes, but how???
Can someone provide me the name of the class/members or a code snipet please?
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
CultureInfo.GetCultures[^]
I didn't check if there was a flag to request primary languages only, but if their isn't, just skip anything that doesn't have the neutral culture as parent.
|
|
|
|
|
Hi Friends,
Sorry for repeating this question. How to sort the datagridview unbounded columns in c#.net.Its urgent for me. Please Help.
Code:
ICollection userDetails = new ArrayList();
domainUser = SessionData.LoginName;
domainPassword = SessionData.Password;
userDetails=GetAllUsers(DEFAULTDOMAIN, domainUser, domainPassword); (Here GetAllUsers is a method which returns all the user details from the domain).
dgAddressBook.DataSource = userDetails;
Full Details are listed in Datagridview. But I need to display the records based on the Column Firstname - ascending order).
Thanks in Advance,
Regards,
Prya
|
|
|
|
|
If you are using framework 2, use a SortedList instead of ArrayList, or a List and use it's Sort method.
Otherwise, you can use the Sort method of the ArrayList.
---
Year happy = new Year(2007);
|
|
|
|
|
THank u so much. I applied it like,
ICollection userDetails = new SortedList();
But the contents are not sorted. Can u pls. suggest me what was the problem.
Regards,
Prya
|
|
|
|
|
The problem is that you are not using the list that you create in that line. The GetAllUsers method returns a new list and the first list is thrown away.
---
Year happy = new Year(2007);
|
|
|
|
|
Hi all,
I have a question that isn't possible store value/data in application instead of in database. What i mean here is even i close my application,those value which are stored/saved is still remain in my application.When next time i run again that application,the value still be the same as before.I know some functions like setting.save() ,but dun know is correct or not.
Can someone give me a hand or guide me to solve it out?any hits are welcome.
thanks in advance.
cocoonwls
|
|
|
|
|
You can use xml file instead of database or also
You can save into the windows registry.
Keep Smiling !!!
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Are you using .NET 2.0 ? In 2.0, there's a properties section that handles saving and loading app data for you.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
hi Christian Graus,
Yes,i am using .NET 2.0. Can you please give me an simple example or related information link?
Thanks,;)
cocoonwls
|
|
|
|
|
Your app has a properties section, in this you can add a property name and value. I believe that Application.Properties.PropName is how you access them.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
hi,
I found it1 But i have one more question,what is the different between user scope and application scope.Thanks alot!
|
|
|
|
|
The values get stored in my documents. Use scope means each user has their own config. Application scope means the app has values the same for all users.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Further to this.
If you are using C#, expand Properties in Solution Explorer and open Settings.settings. Add your settings here. Access your settings in-code with:
something = Properties.Settings.Default.MySetting
or
something = Properties.Settings.Default["MySetting"];
if you have edited User settings during runtime and wish to save them, call:
Properties.Settings.Default.Save();
User settings:
*Can be changed and saved during runtime.
*Get stored in ...\Documents and Settings\Application Data\<appname>
Application settings:
*Cannot be edited during runtime.
*Get stored in the application folder.
-- modified at 4:30 Tuesday 23rd January, 2007
|
|
|
|
|
Personally I try to keep all needed data in a serializable object.
Then before closing i serialize the object into a string, and store the string in a registry key.
At Loading Registry Key existance an value validity is checked.If that goes ok, deserialization occurs and everything is fine.
To accomplish that i have created some objects with static functions to use in every application.
|
|
|
|
|
Hi All,
I am working with Windows Forms using C#, i have a treeview populated with nodes, child nodes and further subnodes, I need to create a BACK button using which i need to track back the previous node selections on treeview just similar to BACK button on IE.
I appreciate any kind of help through code sample.
Thank you
|
|
|
|
|
You can try it, when click on back button.........
If Not (TreeView.SelectedNode.PrevVisibleNode Is Nothing) Then
TreeView.SelectedNode = TreeView.SelectedNode.PrevVisibleNode
TreeView.Focus()
End If
It helpful for u...................
Keep Smiling !!!
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Do something like this:
1) Make sure you are using System.Collections;
2) Declare ArrayList history; in your Form derived class (let it be Form1 ), and treeView1 your TrieView control;
3) Initialize history in Form1_Load(object sender, EventArgs e) :
history = new ArrayList();
4) In the private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) handler, write this piece of code:
TreeNode tn = treeView1.SelectedNode;<br />
if (tn != null) history.Add(tn);
5) In the private void YourGoBackButton_Click(object sender, EventArgs e) , write this piece of code:
if (history.Count < 2) return;<br />
treeView1.AfterSelect -= new System.Windows.Forms.TreeViewEventHandler(treeView1_AfterSelect);<br />
TreeNode tn = (TreeNode)history[history.Count - 2];<br />
history.RemoveAt(history.Count - 1);<br />
treeView1.SelectedNode = tn;<br />
while (tn != null)<br />
{<br />
tn.Expand();<br />
tn = tn.Parent;<br />
}<br />
treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeView1_AfterSelect);<br />
treeView1.Focus();<br />
Enjoy!
SkyWalker
|
|
|
|