Click here to Skip to main content
15,891,184 members
Home / Discussions / C#
   

C#

 
QuestionHandling .class files in C# Pin
Dsypher4-Oct-05 1:07
Dsypher4-Oct-05 1:07 
AnswerRe: Handling .class files in C# Pin
g00fyman4-Oct-05 3:19
g00fyman4-Oct-05 3:19 
AnswerRe: Handling .class files in C# Pin
Daniel Grunwald4-Oct-05 5:56
Daniel Grunwald4-Oct-05 5:56 
Questionbuild a forum Pin
Venkat60704-Oct-05 0:50
Venkat60704-Oct-05 0:50 
AnswerRe: build a forum Pin
ehuysamer4-Oct-05 4:05
ehuysamer4-Oct-05 4:05 
Questionshowing data in datagrid from two relational tables Pin
Rizwan Bashir4-Oct-05 0:50
Rizwan Bashir4-Oct-05 0:50 
AnswerRe: showing data in datagrid from two relational tables Pin
Robert Rohde4-Oct-05 1:17
Robert Rohde4-Oct-05 1:17 
QuestionError creating .exe Pin
sean_mufc4-Oct-05 0:42
sean_mufc4-Oct-05 0:42 
Hello,

I am trying to write a simple console app that reads the data contained in specific Excel spreadsheet cells, and use that data to write an .xml file with the XmlTextWriter class. when I go to compile the code, I get an error that says it does not recognise 'using Excel;' and that I may be missing a reference. The thing is I had already added the Excel reference from the Project > Add Reference.. dialog. I run into this error before when writing to an Excel worksheet and after I clicked 'Yes' to continue in the 'Build Errors' dialog, the app ran perfectly, but not this time.
I now get an error that says VS cannot start debugging beacuse the debug target <path>\Program.exe is missing. I have never seen this before, can anyone help me?

The code below is an extract on my class:

class Program
{
static void Main(string[] args)
{
//directory of XLS file to be read from
string xlsDir = "";
bool xlsError = false;

XmlTextWriter writer = new XmlTextWriter("C:\\My Documents\\test1.xml", _UnicodeEncoding);
writer.Formatting = Formatting.Indented;

int countVPS = 0; //to increment the VPSnodes array
string[] VPSnodes = new string[5] { vendorID, vendor, copyright, version, _schemaVersion };


//opens dialog to browse directories and open a file
OpenFileDialog openFile = new OpenFileDialog();
openFile.InitialDirectory = "c:\\My Documents";
openFile.Filter = "xls files (*.xls)|*.xls*|xml files (*.xml)*.xml*|
_All files (*.*)|*.*";

if (openFile.ShowDialog() == DialogResult.OK)
{
xlsDir = openFile.FileName;
Excel.Workbook wb = this.Application.Workbooks.Open(xlsDir);
// activate the active worksheet in the workbook

(Microsoft.Office.Interop.Excel._Workbook)
_this.Application.Workbooks[1]).Activate();
((Excel.Worksheet)this.Application.ActiveWorkbook.ActiveSheet);

try
{
if (ExcelObj == null)
{
Console.WriteLine("\nERROR: EXCEL couldn't be started!");
xlsError = true;
}

if (xlsError == false)
{
writer.WriteRaw("<vps>");
writer.WriteStartElement("vendorProductSet");

for (int colV = 1; colV <= 5; colV++)
{
writer.WriteAttributeString(nodes[countVPS],
_((Range)ws.Cells[2, col]).Value2);
countVPS++;
}//end VendorProductSetNode

}//end if
writer.Close();
}//end try

catch (Exception e)
{
Console.WriteLine(e);
}//end catch

}//end if
}//end main
}//end class
QuestionReplace a block of text file Pin
Bharath KR4-Oct-05 0:38
Bharath KR4-Oct-05 0:38 
AnswerRe: Replace a block of text file Pin
Robert Rohde4-Oct-05 1:33
Robert Rohde4-Oct-05 1:33 
QuestionRe: Replace a block of text file Pin
Sean Michael Murphy4-Oct-05 3:26
Sean Michael Murphy4-Oct-05 3:26 
AnswerRe: Replace a block of text file Pin
Bharath KR4-Oct-05 3:48
Bharath KR4-Oct-05 3:48 
QuestionReturning Custom Errors from a custom Action in Deployment projects Pin
lata07mahi4-Oct-05 0:02
lata07mahi4-Oct-05 0:02 
QuestionProblem with DataAdapter and DataSet Pin
kbalias3-Oct-05 23:18
kbalias3-Oct-05 23:18 
AnswerRe: Problem with DataAdapter and DataSet Pin
Guffa3-Oct-05 23:44
Guffa3-Oct-05 23:44 
QuestionC# Graphics Scaling Pin
michaelreian3-Oct-05 23:15
michaelreian3-Oct-05 23:15 
Questioncustom objects + remoting Pin
g00fyman3-Oct-05 23:11
g00fyman3-Oct-05 23:11 
AnswerRe: custom objects + remoting Pin
Robert Rohde3-Oct-05 23:40
Robert Rohde3-Oct-05 23:40 
GeneralRe: custom objects + remoting Pin
g00fyman3-Oct-05 23:56
g00fyman3-Oct-05 23:56 
QuestionSelect Node in TreeView Pin
mimei3-Oct-05 21:52
mimei3-Oct-05 21:52 
AnswerRe: Select Node in TreeView Pin
mav.northwind3-Oct-05 22:35
mav.northwind3-Oct-05 22:35 
QuestionRedirect ALL http request to local proxy server Pin
Anonymous3-Oct-05 20:22
Anonymous3-Oct-05 20:22 
QuestionDouble.NaN question Pin
User 5838523-Oct-05 20:21
User 5838523-Oct-05 20:21 
AnswerRe: Double.NaN question Pin
leppie3-Oct-05 20:28
leppie3-Oct-05 20:28 
GeneralRe: Double.NaN question Pin
User 5838523-Oct-05 20:32
User 5838523-Oct-05 20:32 

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.