Doofenshmirt
Gebruiker
- Lid geworden
- 3 nov 2011
- Berichten
- 222
Hoi,
gebruik deze code om wat op te slaan als xml bestand.
Weet iemand hoe ik deze code kan aanpassen dat hij wordt opgeslagen in Landscape.
Dat als ik hem print deze als landscape wordt uitgeprint.
gebruik deze code om wat op te slaan als xml bestand.
Weet iemand hoe ik deze code kan aanpassen dat hij wordt opgeslagen in Landscape.
Dat als ik hem print deze als landscape wordt uitgeprint.
Code:
Dim fs As New IO.StreamWriter(savefiledialog1.FileName)
fs.WriteLine("<?xml version=""1.0""?>")
fs.WriteLine("<?mso-application progid=""Excel.Sheet""?>")
fs.WriteLine("<ss:Workbook xmlns:ss=""urn:schemas-microsoft-com:office:spreadsheet"">")
fs.WriteLine(" <ss:Styles>")
fs.WriteLine(" <ss:Style ss:ID=""1"">")
fs.WriteLine(" <ss:Font ss:Bold=""1""/>")
fs.WriteLine(" </ss:Style>")
fs.WriteLine(" </ss:Styles>")
fs.WriteLine(" <ss:Worksheet ss:Name=""Sheet1"">")
fs.WriteLine(" <ss:Table>")
For x As Integer = 0 To DataGridView1.Columns.Count - 1
fs.WriteLine(" <ss:Column ss:Width=""{0}""/>",
DataGridView1.Columns.Item(x).Width)
Next
fs.WriteLine(" <ss:Row ss:StyleID=""1"">")
For i As Integer = 0 To DataGridView1.Columns.Count - 1
fs.WriteLine(" <ss:Cell>")
fs.WriteLine(String.Format(
" <ss:Data ss:Type=""String"">{0}</ss:Data>",
DataGridView1.Columns.Item(i).HeaderText))
fs.WriteLine(" </ss:Cell>")
Next
fs.WriteLine(" </ss:Row>")
For intRow As Integer = 0 To DataGridView1.RowCount - 2
fs.WriteLine(String.Format(" <ss:Row ss:Height =""{0}"">",
DataGridView1.Rows(intRow).Height))
For intCol As Integer = 0 To DataGridView1.Columns.Count - 1
fs.WriteLine(" <ss:Cell>")
fs.WriteLine(String.Format(
" <ss:Data ss:Type=""String"">{0}</ss:Data>",
DataGridView1.Item(intCol, intRow).Value.ToString))
fs.WriteLine(" </ss:Cell>")
Next
fs.WriteLine(" </ss:Row>")
Next
fs.WriteLine(" </ss:Table>")
fs.WriteLine(" </ss:Worksheet>")
fs.WriteLine("</ss:Workbook>")
fs.Close()