Hi to all,
My name is hari, iam trying to delete the column value of spread sheet using c sharp,
iam trying to get the value and compare, when comparing it showing some errors, can any one help me, to slove this issue
i pasted code below - Microsoft.Office.Interop.Excel.Application ObjExcel = new Microsoft.Office.Interop.Excel.Application();
-
Microsoft.Office.Interop.Excel.Workbook ObjWorkBook=null;
-
String s = "ValueToCompare";
-
try
-
{
-
Microsoft.Office.Interop.Excel.Worksheet ObjWorkSheet;
-
Microsoft.Office.Interop.Excel.Worksheet ObjWork;
-
ObjWorkBook = ObjExcel.Workbooks.Open("D:/New Folder/WatiNSample.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
-
-
int workbookCount = ObjWorkBook.Worksheets.Count;
-
for (int r = 0; r <= workbookCount - 1; r++)
-
{
-
ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBook.Worksheets[r + 1];
-
// rng = ObjWorkSheet.get_Range("L1", "L1");
-
string str = (ObjWorkSheet.Cells[13, 13]);
-
ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBook.Worksheets[r + 1];
-
if (s == str)
-
{
-
ObjWorkSheet.get_Range("L1", "L1").EntireColumn.Delete(13);
-
}
-
-
if (File.Exists("D:/New Folder/WatiNSample.xls"))
-
{
-
//File.Delete("D:/New Folder/WatiNSample.xls");
-
}
-
// ObjExcel.Quit();
-
}
-
}
-
catch (FileNotFoundException e)
-
{
-
Console.WriteLine(e.Message);
-
}
-
finally
-
{
-
if (ObjWorkBook != null)
-
{
-
ObjWorkBook.Save(); ObjWorkBook.Close(Microsoft.Office.Interop.Excel.XlSaveAction.xlSaveChanges, Type.Missing, Type.Missing);
-
}
-
ObjExcel = null;
-
}
-
}
thanx
Hari.
2 2516 TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
when comparing it showing some errors,
Help us to help you... where are you getting the errors (what line #)... and what are the errors?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Owen T. Soroke |
last post by:
Using VB.NET
I have a ListView with several columns.
Two columns contain integer values, while the remaining contain string
values.
I am confused as to how I would provide functionality to...
|
by: WStoreyII |
last post by:
Hello,
I was wondering if there was a way to open a spread sheet up in a windows
mdi form. I have tried the spreadsheet control but that does not work
because i wish to open up an exisiting...
|
by: UnaCoder |
last post by:
Hi, I'm trying to use client side JavaScript from an HTML file to open
and make changes to an Excel SpreadSheet using ADO w/ ODBC. What a
pain it is to do this. Anyways, I am able to open the...
|
by: RICHARD BROMBERG |
last post by:
I wrote a small Access application that accepts a City Name and a Street
Name and runs a Query based on them .
I want to create an Excel Spread sheet that contains all the matches found
by the...
|
by: stuart79 |
last post by:
I am looking for a code that enables me to open another excel spread sheet while i am in my XL form i have this code - Workbooks.Open Filename:= "OtherFilename.xls" - which opens up the XL spread...
|
by: glibo |
last post by:
I am trying to change the tab name when i open a excell spread sheet on the run time in c#.
I changed it in the code:
Response.AddHeader("content-disposition","filename=" + sFileName + ".xls");...
|
by: pvenu |
last post by:
Hi,
I know basic perl (regular expressions, pattern matching, string manipulation, reading writing into text files).
Yet, my requirement is to read an input text file -> process this input file...
|
by: Manikandan |
last post by:
Hi,
I'm using office web components11 for my c# application.
I'm creating a excel spread sheet with data's programmatically.
I have written codes for double click event handler.
if the data in...
|
by: cdavii |
last post by:
Anyone have an idea why i get null values when i import data from a ms spread sheet in a sql tbl. The table elemet(Spread sheet) in question contains alpha numerics. The sql table is populated with...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |