|
hi Navneeth
Thanks for ur concern ,
here is my code
initailizing code:
Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
code for Reading from excel:-
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
Workbook CallListWorkBook = objExcel.Workbooks.Open(openFileDialog1.FileName, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 0, 0);
Sheets CallingSheet = CallListWorkBook.Worksheets;
Worksheet worksheet = (Worksheet)CallingSheet.get_Item(1);
Range CallingRange = worksheet.get_Range("A1", "A1");
CallingRange = CallingRange.get_End(XlDirection.xlToRight);
totalColumn = CallingRange.Column;
string downAddress = CallingRange.get_End(XlDirection.xlDown).get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
//string downAddress = CallingRange.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
CallingRange = worksheet.get_Range("A1", downAddress);
System.Array CallingValues = (System.Array)CallingRange.Cells.Value2;
//objExcel.Workbooks.Close();
//objExcel.Quit();
ConvertToStringArray(CallingValues);
}
Code for writing in excel:
Excel.Workbooks CallListWorkBooks;
Excel.Sheets CallingSheet;
Excel._Worksheet worksheet;
Excel.Range CallingRange;
Excel.Workbook CallListWorkBook;
try
{
// Instantiate Excel and start a new workbook.
// objExcel = new Excel.Application();
CallListWorkBooks = objExcel.Workbooks;
CallListWorkBook = CallListWorkBooks.Add(Missing.Value);
CallingSheet = CallListWorkBook.Worksheets;
worksheet = (Excel._Worksheet)CallingSheet.get_Item(1);
//Get the CallingRange where the starting cell has the address
//m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols.
CallingRange = worksheet.get_Range("A1", Missing.Value);
int totalrows = arr.Count;
CallingRange = CallingRange.get_Resize(totalrows, 1);
//Create an array.
string[,] saRet = new string[totalrows, 1];
//Fill the array.
int j = 0;
for (long iRow = 0; iRow < totalrows; iRow++)
{
for (long iCol = 0; iCol < 1; iCol++)
{
//Put a counter in the cell.
saRet[iRow, iCol] = Convert.ToString(arr[j]);
//saRet[iRow, iCol] = Convert.ToDouble(theArray[i, 2]);
j++;
}
}
//Set the CallingRange value to the array.
CallingRange.set_Value(Missing.Value, saRet);
if (IsActive == 1)
{
CallListWorkBook.SaveAs("c:\\Active.xls", Excel.XlFileFormat.xlWorkbookNormal, null, null, false, false, Excel.XlSaveAsAccessMode.xlShared, false, false, null, null, null);
}
else
{
CallListWorkBook.SaveAs("c:\\inactive.xls", Excel.XlFileFormat.xlWorkbookNormal, null, null, false, false, Excel.XlSaveAsAccessMode.xlShared, false, false, null, null, null);
}
objExcelForWriting.Visible = false;
objExcelForWriting.UserControl = false;
CallListWorkBooks.Close();
objExcel.Quit();
}
catch (Exception theException)
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat(errorMessage, theException.Message);
errorMessage = String.Concat(errorMessage, " Line: ");
errorMessage = String.Concat(errorMessage, theException.Source);
MessageBox.Show(errorMessage);
}
}
|
|
|
|
|
why C# interfaces doesn't contain data members?
|
|
|
|
|
Because it doesn't actually implement anything. It only provides a contract that states what methods/properties will be present.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Because that is not the purpose of an interface.
An interface defines the public interface* of a class (or part of a class) that implements the interface.
If you want data members then you should look at implementing an abstract class .
* Note there is a difference between interface and interface
|
|
|
|
|
Hello,
Does anyone know how to elevate Users in Vista progrmatically without any User Interface to appear?
I need to do this in order to install something, which normally can be installed only by an admin, from a lower user account...
Please help me if you can. I need urgent help..
Thanks
L.P.
|
|
|
|
|
I don't believe that this is possible, because it would represent a major security hole in Vista. One of the tenets of Vista is that elevation only happens when the user agrees to it. If it didn't then virus and trojan writers would be able to run rampant throughout Vista.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Lucian.Palcu wrote: Does anyone know how to elevate Users in Vista progrmatically without any User Interface to appear?
You can't. At the point that elevation occurs a dialog is presented on a secured desktop to which the user must be respond. The secure desktop means that processed also cannot hijack the window (by getting hold of its handle) and respond on the user's behalf.
Lucian.Palcu wrote: I need to do this in order to install something, which normally can be installed only by an admin, from a lower user account...
Then I would definitely say you need admin rights for that!
Interestingly Vista contains some funky virtualisation stuff which means that you cannot write to the Program Files directory except as admin. However, for compatibility with older or badly behaved programs if a write is detected it will create a special directory in the user's profile and write the file there to protect the integrity of the system.
|
|
|
|
|
hi,
i need lil help.i want to make a winform in which i have to make a grouppanel which looks the same like the toolbox in the microsoft visual studio.
i want to pick up labels from that panel n want to drop it in the same form.so i want that treeview thing to b the same as in that toolbox. i just want to add labels in that panel n nothing else.
n those labels should b dragable.
plz can anyone guide me with this problem. its very urgent n i got deadlines 4 it
thanks
reply soon.
|
|
|
|
|
The toolbox in Visual Studio is a custom owner-drawn control (based on TreeView I think). To create a control that looks and behaves the same is a non-trivial task. If you're more interested in the functionality and don't need it to look as slick as the VS toolbox, you can use a simple TreeView control.
As for drag and drop, it's pretty simple. Search CodeProject for articles on that topic -- there are several.
|
|
|
|
|
hi I wanted to put some dll in the gac
so I used the gacutil /i XXX.dll
and put it there
but I still couldn't use it in my program,, why?
thanx
|
|
|
|
|
You have added a reference to it in your project haven't you?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
check you have that dll copied into gac ? open assembly folder and check
|
|
|
|
|
Hi Friends
How a size of a class can be determined? As an example
Class A
{
}
Class A
{
int i;
public A()
{
i=10;
}
}
Class B
{
A aa=new A()
public B()
{
}
}
What would be the size of object of type A and B ??
Thanks in advance.
Thanks,
Arindam D Tewary
|
|
|
|
|
Unfortunately, there's no quick and easy way (unless you're using Mono where Marshal.SizeOf returns the size of a type in managed code). Common methods for working with size information include using GC.GetTotalMemory, but this is not fine grained enough for the type of detail you want.
A better alternative is to use the .NET profiling API. Unfortunately, this means that you are probably going to get down and dirty with C++.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
I have developed C#.net Windows Application and I've to open and write in Console window thru my Windows application.
Pls help me to resolve this issue.
Thx in Advance
Vidhya
|
|
|
|
|
try System.Diagnostics.Process.Start("cmd.exe);
rahul
|
|
|
|
|
Hi Rahul..
I tried . Thx... But i need to write into Console window thru Win exe Code also
Could u pls help
Vidhya
-- modified at 6:15 Thursday 8th March, 2007
|
|
|
|
|
Hi
The easy way is start your windows project as a console application.
To do this go to
Project\properties\Common properties\General
Change the value Output Type from Windows Application to Console Application.
Now run the project.
You will see that a console window will be opened fist which then launches the windows application what ever you write using Console.WriteLine will now appear on the Console window.
Please let me know if this helps
Neo
|
|
|
|
|
Hi Neo,
Thx a lot for timely help .. It works fine...
Vidhya
|
|
|
|
|
hi i want to pass a parameter in crystal report..
i want one complete example..
|
|
|
|
|
Hi
I have an example but are you using Crystal Report 10 with VS2005??
Harini
|
|
|
|
|
|
Hi,
Sorry, I was trying in VS2005. Let me try out with good example and will mail you definitely.
Harini
|
|
|
|
|
|
Hi guys,does anyone of you know how I can implement the recording of screen activity and saving it into a common format like wmv,avi,mpeg ? What are the namespaces I can reference and how is ActiveX able to help me to achieve the functionality?
"Facts do not cease to exist because they are ignored." Aldous Huxley
|
|
|
|
|