Re: export DGV to word ~ excel
1/ i'm not sure of how to tackle that. it'd probably be best to format the dateTime in the items array after reading the dgv
2/ that's a whole new program. there are plenty of examples either here on vbforums or you can find them through google. sorry i couldn't be more help.
1 Attachment(s)
Re: export DGV to word ~ excel
Here are the errors I get from this code
Attachment 96075
Re: export DGV to word ~ excel
ok I got it
change
Code:
Excel.ApplicationClass xlapp = new Excel.ApplicationClass();
to this
Code:
Excel.Application xlapp = new Excel.Application();
Re: export DGV to word ~ excel
you're not using excel 2007 then... sorry i didn't get back to you earlier.
Re: export DGV to word ~ excel
Not a problem..yeah I'm using 2010
Re: export DGV to word ~ excel
HI,
I'm posting the questions I have in this topic as I'm trying to adapt the code paul has provided in the zip file.
I've got VS2010 and MS Office 2010 as environment. I'm only using the Export to EXCEL part.
My question: I'd like to be able to chose the worksheet I'm pasting the selection on.
I've already done this adjustment from your code to be able to chose the starting cell:
Code:
Dim range As Excel.Range= xlWorkSheet.Range("I62").Resize(items.length,headerText.length)
Which doesn't use the alphabet() array anymore.
As to which sheet is concerned I tried this:
Code:
Dim xlWkSheet As Excel.Worksheet=Ctype (xlWorkBook.Worksheets(Index:=1), excel.Worksheet)
It has worked, but when I tried to change the "Index" it caused an error and range.select() was highlighted.
How would one chose what worksheet is the target ?
Re: export DGV to word ~ excel
Hey .paul.,
I've just come across your code and it work's great. I am trying this using late binding. Please let me know how I would do the following using late binding:
Quote:
range.Borders(excel.XlBordersIndex.xlDiagonalUp).LineStyle = excel.XlLineStyle.xlLineStyleNone
Re: export DGV to word ~ excel
try this:
Code:
xlApp = CreateObject("Excel.Application")
...
range.Borders(xlApp.XlBordersIndex.xlDiagonalUp).LineStyle = xlApp.XlLineStyle.xlLineStyleNone
Re: export DGV to word ~ excel
Thanks. I get this error:
Quote:
Public member 'XlBordersIndex' on type 'ApplicationClass' not found.
on this line of code:
Quote:
objRange.Borders(xlApp.XlBordersIndex.xlDiagonalUp).LineStyle = xlApp.XlLineStyle.xlLineStyleNone
Re: export DGV to word ~ excel
all of the members of the XlBordersIndex enum have an integer value, as do the members of the XlLineStyle enum, + the XlBorderWeight enum.
Re: export DGV to word ~ excel
hey .paul.
another question. I have a datagridview combobox column. When I export to Excel the Integer value of the combo is printed. How do I go about getting the text value for combobox columns in my export code?