Click here to Skip to main content
15,898,035 members
Home / Discussions / C#
   

C#

 
QuestionHow i can user User Control in my own Form Pin
wasimsharp24-Dec-07 21:23
wasimsharp24-Dec-07 21:23 
AnswerRe: How i can user User Control in my own Form Pin
Xmen Real 25-Dec-07 2:53
professional Xmen Real 25-Dec-07 2:53 
GeneralRe: How i can user User Control in my own Form Pin
wasimsharp25-Dec-07 19:33
wasimsharp25-Dec-07 19:33 
GeneralRe: How i can user User Control in my own Form Pin
Xmen Real 26-Dec-07 0:40
professional Xmen Real 26-Dec-07 0:40 
GeneralPrint Screen Pin
half-life24-Dec-07 20:19
half-life24-Dec-07 20:19 
GeneralRe: Print Screen Pin
Giorgi Dalakishvili24-Dec-07 20:24
mentorGiorgi Dalakishvili24-Dec-07 20:24 
GeneralSystem.ArgumentException Assistance Needed... [modified] Pin
new_phoenix24-Dec-07 13:38
new_phoenix24-Dec-07 13:38 
QuestionExcel to XML converter with VC# [modified] Pin
iyepb024-Dec-07 10:03
iyepb024-Dec-07 10:03 
Hi everyone...A newbie is confuse here, so please help...and before we start, please aplogize for my bad english Big Grin | :-D
OK, lets start.

I have a task to make an XML file from unusual Excel file...i'm giving the screenshot...please follow the link

http://img227.imageshack.us/img227/1637/capthd0.jpg

So, as u can see that the spreadsheet is not a good looking one...and i've been trying to convert it into an XML file....with reading many tutors...
The file (.xls) is different in the field name (such as "TMPT LHR" can be "TMPT_LHR" or "TMPTLHR" in other xls file) between another...and it is make me crazy doing for one single file...not yet another file :P

Here are methods that i tried:

1. with XML Schema in the Excel view source...not really good at it (my kowledge), cause my test went bad, the XML file output doesn't go as i wish, it messy..
2. Save As the spreadsheet as CSV, and i found it like this...please follow the link...it more make me confuse..
http://img84.imageshack.us/img84/8210/csvfj3.jpg
3. Save As the spreadsheet as Text, and dont get any idea how to convert it...
4. Save As the spreadsheet as XML Spreadsheet, and i try to read the <data> tag/node in it and finally succeded reading the element string (inside the <data>) using VC#... and try to make a well formed XML file...this part not done yet...

This is the code..

start***** this is the code for reading the node****
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace test1
{
public partial class Form1 : Form
{
public String fileName;
public String dbconnect;
public String strNodeValues;
//public String[] strNodeValues3a = new String[3] { "", "", "" }; &lt;- the 3 top field from excel
//public String[] strNodeValues3b = new String[3] { "", "", "" }; &lt;- the 1 record under the 3 top filed
//public String[] strNodeValues15a = new String[15] { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; &lt;- the 15 field under the 1 record
//public String[] strNodeValues15b = new String[15] { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }; &lt;- wish this line to held the 15 data of 1 record, that can be not just one record...see pict above please...

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{


}

private void button1_Click_1(object sender, EventArgs e)
{
Stream myStream;
// String fileName;
OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "xml files (*.xml)|*.xml";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
myStream.Close();
fileName = openFileDialog1.FileName;
textBox1.Text = fileName;
}
}
}

private void button2_Click(object sender, EventArgs e)
{
XmlTextReader reader = new XmlTextReader(fileName);
while (reader.Read())
{
switch (reader.Name)
{
case "Data ":
reader.Read();
strNodeValues = reader.Value;
MessageBox.Show(reader.Value, "Ini " + strNodeValues); &lt;- i see it with message box. Big Grin | :-D
break;
}
}
}

private void button7_Click(object sender, EventArgs e)
{
listBox1.Items.Add(textBox2.Text);
}

private void button8_Click(object sender, EventArgs e)
{
listBox1.Items.Remove(listBox1.SelectedItem);
}

}
}
End***** this is the code for reading the node****

start***** this is the code (class file) for making the XML file**** I edited it from a log generator... Big Grin | :-D
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace test1
{
class bknxml
{
private const string FILE_NAME = "Logimp.log";
StreamWriter sw = null;

public bknxml()
{
if (File.Exists(FILE_NAME))
sw = File.AppendText(FILE_NAME);
else
{
sw = File.CreateText(FILE_NAME);
sw.WriteLine("");
//sw.WriteLine("Generated log by Aplikasi XML Import for PL/SQL error reporting on " + DateTime.Now.DayOfWeek + " at " + DateTime.Now);
}
}

public void writexml(params string[] file)
{
sw.WriteLine("<data_sync>");
foreach (string f in file)
{
sw.WriteLine(" <kk_wni>");
sw.WriteLine(f);
sw.WriteLine(" </kk_wni>");
}
sw.WriteLine("</data_sync>");
sw.WriteLine("");
}

public void closefile()
{
sw.Close();
}
}
}
End***** this is the code for making the XML file****

start***** this is how i want the XML well formed look like****
<data_sync>
<kk_wni>
<no_transaksi>73710110006102006000004</no_transaksi>
<no_kk>7371010610060003</no_kk>
<alamat>JL. BANTAENG 10</alamat>
<rt>001</rt>
<rw>001</rw>
<kd_pos>90221</kd_pos>
<telp> </telp>
<dusun> </dusun>
<kd_wilayah>7371011001</kd_wilayah>
<nama_rt> </nama_rt>
<nama_rw> </nama_rw>
<nama_ptgs_reg> </nama_ptgs_reg>
<nip_ptgs_reg> </nip_ptgs_reg>
<nama_pjbt> </nama_pjbt>
<nip_pjbt> </nip_pjbt>
<created_date>2006-10-06T15:21:22.0000000+08:00</created_date>
<created_by>Febby Ekadiarta</created_by>
<updated_by> </updated_by>
<tgl_transaksi>2006-10-19T09:07:54.0000000+08:00</tgl_transaksi>
</kk_wni>
<kk_wni>
<no_transaksi>73710110006102006000001</no_transaksi>
<no_kk>7371010610060001</no_kk>
<alamat>JL. BANTAENG 10</alamat>
<rt>001</rt>
<rw>001</rw>
<kd_pos>90221</kd_pos>
<telp> </telp>
<dusun> </dusun>
<kd_wilayah>7371011001</kd_wilayah>
<nama_rt> </nama_rt>
<nama_rw> </nama_rw>
<nama_ptgs_reg> </nama_ptgs_reg>
<nip_ptgs_reg> </nip_ptgs_reg>
<nama_pjbt> </nama_pjbt>
<nip_pjbt> </nip_pjbt>
<created_date>2006-10-06T15:12:48.0000000+08:00</created_date>
<created_by>Febby Ekadiarta</created_by>
<updated_by> </updated_by>
<tgl_transaksi>2006-10-19T09:07:54.0000000+08:00</tgl_transaksi>
</kk_wni>
</data_sync>
End***** this is how i want the XML well formed look like****

I want the XML to be look like the above...cause i already made a single application that can inserting the xml data into an oracle table with XML style....and would kindly share to other...

SO...Mr and Mrs Expert please help me...
1. Which is the best method that i have to use? Would you kindly suggest me some better method?
2. If it is not to hard for you to kindly help me, please help me coding the code...the XML Spreadsheet reader and the XML creator...

Please send me mail...if anyone would kindly collaborate coding with this stupid newbie Big Grin | :-D
send it to: me.iyepb0@gmail.com, or YM: me.iyepb0@yahoo.com

To be honest...its been 1 month i'm starting learning VC#...and i was not really a programmer mindset...just drop from colledge... Big Grin | :-D

Thank you for you guys who will be and helping this stupid newbie...tx</data></data>

<div class="ForumMod">modified on Monday, December 24, 2007 4:18:44 PM</div>
GeneralRe: Excel to XML converter with VC# Pin
Ed.Poore25-Dec-07 14:35
Ed.Poore25-Dec-07 14:35 
GeneralRe: Excel to XML converter with VC# Pin
Waleed Eissa25-Dec-07 17:52
Waleed Eissa25-Dec-07 17:52 
GeneralRe: Excel to XML converter with VC# Pin
yonision8-Jan-10 12:58
yonision8-Jan-10 12:58 
QuestionHow to hide a property from the property grid while still allowing XML serialization Pin
slipster21624-Dec-07 9:52
slipster21624-Dec-07 9:52 
AnswerRe: How to hide a property from the property grid while still allowing XML serialization Pin
darkelv24-Dec-07 14:31
darkelv24-Dec-07 14:31 
GeneralRe: How to hide a property from the property grid while still allowing XML serialization Pin
slipster21624-Dec-07 17:43
slipster21624-Dec-07 17:43 
GeneralRe: How to hide a property from the property grid while still allowing XML serialization [modified] Pin
darkelv24-Dec-07 19:05
darkelv24-Dec-07 19:05 
GeneralPrinting Pin
half-life24-Dec-07 4:48
half-life24-Dec-07 4:48 
GeneralRe: Printing Pin
Xmen Real 24-Dec-07 14:50
professional Xmen Real 24-Dec-07 14:50 
GeneralRe: Printing Pin
half-life24-Dec-07 20:08
half-life24-Dec-07 20:08 
GeneralRe: Printing Pin
Xmen Real 24-Dec-07 20:17
professional Xmen Real 24-Dec-07 20:17 
GeneralProblem to override OnTextChanged(throw Unlimited Loop) Pin
hdv21224-Dec-07 4:39
hdv21224-Dec-07 4:39 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
Colin Angus Mackay24-Dec-07 4:57
Colin Angus Mackay24-Dec-07 4:57 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
hdv21224-Dec-07 7:37
hdv21224-Dec-07 7:37 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
Colin Angus Mackay24-Dec-07 9:20
Colin Angus Mackay24-Dec-07 9:20 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
hdv21224-Dec-07 12:40
hdv21224-Dec-07 12:40 
GeneralRe: Problem to override OnTextChanged(throw Unlimited Loop) Pin
Colin Angus Mackay24-Dec-07 13:04
Colin Angus Mackay24-Dec-07 13:04 

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.