|
Yes, Excel files are encoded in XML.
So to get started you can include following namespaces in the codebehind of your page:
System.Xml (work with XML objects)
System.IO (read/write to files)
The Internet is full of code example that show you how to use them.
http://support.microsoft.com/kb/301228[^]
.
|
|
|
|
|
It depends on the version of Excel format the file is saved in. If it's in 2003 and below, it's a multiple stream binary file that will be just about impossible to decipher. If it's 2007 and above, it'll be a .ZIP format file with multiple XML files inside of it. Again, a royal pain to decipher without the SDK. Seriously, save yourself MONTHS of work and use the Visual Studio Tools for Office to do this.
|
|
|
|
|
string stmp = "\n<rs:data ItemCount=\"6\" xmlns:rs=\"urn:schemas-microsoft-com:rowset\">\n <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нÑ\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"3049\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Татнефть УÐ*С\" BdcIdentity=\"__bg01003300030043009300\" xmlns:z=\"#RowsetSchema\" />\n <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нÑ\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"5328\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Ð*озница\" BdcIdentity=\"__bg01005300330023008300\" xmlns:z=\"#RowsetSchema\" />\n <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нÑ\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"5353\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Медуница\" BdcIdentity=\"__bg01005300330053003300\" xmlns:z=\"#RowsetSchema\" />\n <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нÑ\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"5357\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Оптовик\" BdcIdentity=\"__bg01005300330053007300\" xmlns:z=\"#RowsetSchema\" />\n <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нÑ\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"8372\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Ðртемьев ИП\" BdcIdentity=\"__bg01008300330073002300\" xmlns:z=\"#RowsetSchema\" />\n <z:row _x041a__x043b__x0438__x0435__x043d__x0442___x043a__x043e__x0434_=\"16440042770нÑ\" _x0424__x0438__x043b__x0438__x0430__x043b___x041a__x043e__x0434_=\"20706\" _x041a__x043e__x0434_=\"8620\" _x041d__x0430__x0437__x0432__x0430__x043d__x0438__x0435_=\"Шифа\" BdcIdentity=\"__bg01008300630023000300\" xmlns:z=\"#RowsetSchema\" />\n</rs:data>\n";
XmlDocument xd = new XmlDocument();
xd.LoadXml(stmp);
DataSet dsQuery = new DataSet();
var node = xd.DocumentElement as XmlNode;
XmlReader reader1 = new XmlNodeReader(node);
dsQuery.ReadXml(reader1);
var v1 = dsQuery.Tables["row"].Rows[4]["_x041a__x043e__x0434_"];
var v2 = dsQuery.Tables["row"].Rows[4][dsQuery.Tables["row"].Columns[2].ColumnName];
The line with v1 throws an exception:
Column '_x041a__x043e__x0434_' does not belong to table row.
The line with v2 throws no exception, however it returns an empty value instead of expected integer value. I wonder why it happens and how to force dataset to work with my XML correctly?
|
|
|
|
|
I neglected to include my DB creation script in my Git repo to bring it home for some weekend get-ahead work. Now I thought the lauded 'Generate Database from Model' feature would be my saviour here, but it's useless. It uses the entity set names to generate table names, so where all my original table names were singular, the generated ones are plural.
Some wag at StackOverflow suggested making all the entity set names singular but all I can think of is somehow extracting all original table names, generating the script, then doing a marathon search and replace. Any suggestions on how I could do this? Any other suggestions?
Disclaimer: This is a duplicate of my StackOverflow question here.
|
|
|
|
|
When I run the .net Reflector,I got a Error,it says the "\UIAutomaionProvider damaged and can't read".
I just can run it well the days before.
|
|
|
|
|
|
Actually i have more than 10 columns....in designing form i have 2 dropdownlist and 2 textboxes..
1-Dropdownlist-for select the state
2-Dropdownlist -for choose the column name like temperature, sea level,etc..
3-textbox-for select start date
4-textbox-for select end date
Now i wanna generate chart for this functions...whenever i choose the state and temperature and start date and end date i need to generate chart for this process.
I wanna shows details in chart in between date from start date to end date...
Pls give ur idea for this process....
Deenuji
|
|
|
|
|
Hey..I'm new to VB.net programming and i'm having a problem with my project.
here's a sample code
Private Sub MinsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MinsToolStripMenuItem.Click
Dim b As Boolean
MsgBox(" pop up will return on " & Now.AddMinutes(5))
Dim a = Now.AddMinutes(5)
Try
b = System.Convert.ToBoolean(a)
Catch exception As System.InvalidCastException
If a = True Then
PopupNotifier1.Popup()
End If
End Try
End Sub
What i want is that after I click the MinsToolStripMenuItem, it will wait for five mins and after that, popupnotifier will popup..
Any help is greatly appreciated..
|
|
|
|
|
Following should do it:
System.Threading.Thread.Sleep(30000)
|
|
|
|
|
+5
Jibesh V P
|
|
|
|
|
Hi All,
I am using Entity Framework 1.0, I have Claims Table as master table and Requests Table as details table. First I am deleting data from Requests (details) table and then I am trying to delete data from master table.
Even though there is no record exists in Requests table I am unable to delete rows from Claims table, it is throwing FK relationship exception. What could be the reason? I am not understaing because when there is no recod exists in Details table for the Master table record. Then that record in Master table should be easily deleted.
I am trying my best to resolve is, any body if they have any idea please help me.
I am trying to google too, but if anybody have any idea, it would be great if they help me.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Why on earth are you using EF 1.0?? It was a nice idea, but lacked SOOO much usable stuff it wasn't really worth anything.
EF 5 is out now and is FAR better than 1.0.
|
|
|
|
|
indian143 wrote: any body if they have any idea please help me.
Some general possibilities
- There is still something in details.
- The way you coded the details delete in the framework is wrong.
- The framework is handling the delete for you as a batch but when it does the real commit it is doing the master delete first.
|
|
|
|
|
Hi all,
I need to pu an image in a button but my application runs in Windows CE so I'm using the Compact Framework and in this context the object Button has no property like Image , BackgroundImage , Bitmap or something similar.
Anybody knows how I can do?
Thanks to all.
|
|
|
|
|
steve_9496613 wrote: Anybody knows how I can do?
Try MSDN[^]
|
|
|
|
|
Well... I can't say that I have understood everything in the MSDN example but I managed to convert it to Visual Studio .NET 2008 and to make it work!!!!
Yes, it would be easier something like Button.BkImage("image.bmp") but ... it seems that the Compact Framework is missing many things that I need!!!
Once again, Thank you Eddy!!
I publish the code of MyImageButton class if it can help someone or anyone has any corrections to suggest.
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Drawing.Imaging
Public Class MyImageButton
Inherits Control
Private image As Image
Private FirstTime As Boolean = True
Private bPushed As Boolean
Private m_bmpOffscreen As Bitmap
Sub New()
bPushed = False
Me.Size = New Size(21, 21)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim gxOff As Graphics
Dim imgRect As Rectangle
Dim backBrush As Brush
If (FirstTime) Then
m_bmpOffscreen = New Bitmap(ClientSize.Width, ClientSize.Height)
End If
gxOff = Graphics.FromImage(m_bmpOffscreen)
gxOff.Clear(Me.BackColor)
If (Not bPushed) Then
backBrush = New SolidBrush(Parent.BackColor)
Else
backBrush = New SolidBrush(Color.LightGray)
End If
gxOff.FillRectangle(backBrush, Me.ClientRectangle)
If (Not image.Equals(DBNull.Value)) Then
Dim imageLeft As Int32 = (Me.Width - image.Width) / 2
Dim imageTop As Int32 = (Me.Height - image.Height) / 2
If (Not bPushed) Then
imgRect = New Rectangle(imageLeft, imageTop, image.Width, image.Height)
Else
imgRect = New Rectangle(imageLeft + 1, imageTop + 1, image.Width, image.Height)
End If
Dim imageAttr As ImageAttributes = New ImageAttributes()
imageAttr.SetColorKey(BackgroundImageColor(image), BackgroundImageColor(image))
gxOff.DrawImage(image, imgRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttr)
End If
If (bPushed) Then
Dim rc As Rectangle = Me.ClientRectangle
rc.Width -= 1
rc.Height -= 1
gxOff.DrawRectangle(New Pen(Color.Black), rc)
End If
e.Graphics.DrawImage(m_bmpOffscreen, 0, 0)
MyBase.OnPaint(e)
End Sub
Private Function BackgroundImageColor(ByVal image As Image) As Color
Dim bmp As Bitmap = New Bitmap(image)
Return bmp.GetPixel(0, 0)
End Function
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaintBackground(e)
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
bPushed = True
Me.Invalidate()
MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
bPushed = False
Me.Invalidate()
MyBase.OnMouseUp(e)
End Sub
Public Property MImage() As Image
Get
Return image
End Get
Set(ByVal value As Image)
image = value
End Set
End Property
End Class
|
|
|
|
|
You're welcome
steve_9496613 wrote: I publish the code of MyImageButton class if it can help someone or anyone has any corrections to suggest.
It might get buried under new messages on the forum here; it'd be more visible if you post it as a "Tip[^]".
|
|
|
|
|
You can use Label instead button and lay text over image.
|
|
|
|
|
Thank you halabella for your answer.
It can be a possibility but in this way I think you lose the behavior of the button (button pressed - button not pressed).
In my particular case I could just use an image because the text I need to write is a symbol of a font type not included in my Windows CE (for this reason I need to put an image in a button) but there would be much difference aesthetically with the other buttons of the form.
...but perhaps I could change the image on the click event... yes, it is a possibility.
Thanks
|
|
|
|
|
Hi steve,
You can use ImageButton control. An attribute called ImageUrl is where you specify the path to your image.
Hope that have you. Happy coding!
|
|
|
|
|
Hi s3275049,
thank you for your replay but unfortunately MSDN says that the ImageButton class is not supported in the Windows CE platform.
|
|
|
|
|
Hi all,
I need to extract each byte from a 32 bit value.
I did something like this but it doesn't work:
Dim b1, b2, b3, b4 As Byte
Dim SingleVal As Single
SingleVal = 0.125
b1 = SingleVal And &HFF
b2 = (SingleVal >> 8) And &HFF
b3 = (SingleVal >> 16) And &HFF
b4 = (SingleVal >> 24) And &HFF
I'm not sure that the >> operator works in the right way on a Single value.
What is the right way to do this?
Thanks to all.
|
|
|
|
|
steve_9496613 wrote: What is the right way to do this?
Don't know if it helps, but there's a <a href="http://msdn.microsoft.com/en-us/library/de8fssa4.aspx">BitConverter</a>[<a href="http://msdn.microsoft.com/en-us/library/de8fssa4.aspx" target="_blank" title="New Window">^</a>] available. There's an example of it's usage on the same page.
|
|
|
|
|
Thank you very much Eddy, it works:
Dim b() As Byte
Dim SingleVal As Single
SingleVal = 0.125
b = BitConverter.GetBytes(SingleVal)
As always your answers are very helpful!
|
|
|
|
|
Thanks
|
|
|
|