I am attempting to delete duplicate rows in a spreadsheet using the Excel object.
Does anyone have any idea how to do this? I've looked everywhere that I can find on the Web and have not been able to find anything on it.
What I have so far is:
Excel.Range range = oSheet.get_Range("A1", Type.Missing);
range = range.get_End(Excel.XlDirection.xlDown);
string downAddress = range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
range = oSheet.get_Range("A1",downAddress);
object[,] values = (object[,])range.Value2;
for (int i = 2; i < values.GetLength(0); i++)
{
if (values[i-1,1].ToString() == values[i,1].ToString())
{
// This is where I want to delete the row.
}
any help would be greatly appreciated. 6 16090
Check out this link http://msdn.microsoft.com/library/de...l/ExcelObj.asp . ANd you are looking for the clear cell info.
Cheers,
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:ui*************@TK2MSFTNGP12.phx.gbl...
I am attempting to delete duplicate rows in a spreadsheet using the Excel object.
Does anyone have any idea how to do this? I've looked everywhere that I can find on the Web and have not been able to find anything on it.
What I have so far is:
Excel.Range range = oSheet.get_Range("A1", Type.Missing);
range = range.get_End(Excel.XlDirection.xlDown);
string downAddress = range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
range = oSheet.get_Range("A1",downAddress);
object[,] values = (object[,])range.Value2;
for (int i = 2; i < values.GetLength(0); i++)
{
if (values[i-1,1].ToString() == values[i,1].ToString())
{
// This is where I want to delete the row.
}
any help would be greatly appreciated.
I want to delete the entire row... I have a range of 1280 rows that I want to remove the duplicate rows... I'm not sure I understand how the "clear cell info" is going to help with that.
"Denis Dougall" <De***********@here.there.com> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl...
Check out this link http://msdn.microsoft.com/library/de...l/ExcelObj.asp . ANd you are looking for the clear cell info.
Cheers,
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:ui*************@TK2MSFTNGP12.phx.gbl...
I am attempting to delete duplicate rows in a spreadsheet using the Excel object.
Does anyone have any idea how to do this? I've looked everywhere that I can find on the Web and have not been able to find anything on it.
What I have so far is:
Excel.Range range = oSheet.get_Range("A1", Type.Missing);
range = range.get_End(Excel.XlDirection.xlDown);
string downAddress = range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
range = oSheet.get_Range("A1",downAddress);
object[,] values = (object[,])range.Value2;
for (int i = 2; i < values.GetLength(0); i++)
{
if (values[i-1,1].ToString() == values[i,1].ToString())
{
// This is where I want to delete the row.
}
any help would be greatly appreciated.
You can then iterate through and delete the empty cells/rows and preserve your formulae. However here is some delete row code.
Range(x,y ).EntireRow.Delete
Range(Cells(1, 1), Cells(99, ubound var)).EntireColumn.Delete
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:eu**************@TK2MSFTNGP11.phx.gbl...
I want to delete the entire row... I have a range of 1280 rows that I want to remove the duplicate rows... I'm not sure I understand how the "clear cell info" is going to help with that.
"Denis Dougall" <De***********@here.there.com> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl...
Check out this link http://msdn.microsoft.com/library/de...l/ExcelObj.asp . ANd you are looking for the clear cell info.
Cheers,
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:ui*************@TK2MSFTNGP12.phx.gbl...
I am attempting to delete duplicate rows in a spreadsheet using the Excel object.
Does anyone have any idea how to do this? I've looked everywhere that I can find on the Web and have not been able to find anything on it.
What I have so far is:
Excel.Range range = oSheet.get_Range("A1", Type.Missing);
range = range.get_End(Excel.XlDirection.xlDown);
string downAddress = range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
range = oSheet.get_Range("A1",downAddress);
object[,] values = (object[,])range.Value2;
for (int i = 2; i < values.GetLength(0); i++)
{
if (values[i-1,1].ToString() == values[i,1].ToString())
{
// This is where I want to delete the row.
}
any help would be greatly appreciated.
I've tried that, but I keep getting "'object' does not contain a definition for 'EntireRow'".
"Denis Dougall" <De***********@here.there.com> wrote in message news:Ok*************@TK2MSFTNGP14.phx.gbl...
You can then iterate through and delete the empty cells/rows and preserve your formulae. However here is some delete row code.
Range(x,y ).EntireRow.Delete
Range(Cells(1, 1), Cells(99, ubound var)).EntireColumn.Delete
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:eu**************@TK2MSFTNGP11.phx.gbl...
I want to delete the entire row... I have a range of 1280 rows that I want to remove the duplicate rows... I'm not sure I understand how the "clear cell info" is going to help with that.
"Denis Dougall" <De***********@here.there.com> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl...
Check out this link http://msdn.microsoft.com/library/de...l/ExcelObj.asp . ANd you are looking for the clear cell info.
Cheers,
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:ui*************@TK2MSFTNGP12.phx.gbl...
I am attempting to delete duplicate rows in a spreadsheet using the Excel object.
Does anyone have any idea how to do this? I've looked everywhere that I can find on the Web and have not been able to find anything on it.
What I have so far is:
Excel.Range range = oSheet.get_Range("A1", Type.Missing);
range = range.get_End(Excel.XlDirection.xlDown);
string downAddress = range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
range = oSheet.get_Range("A1",downAddress);
object[,] values = (object[,])range.Value2;
for (int i = 2; i < values.GetLength(0); i++)
{
if (values[i-1,1].ToString() == values[i,1].ToString())
{
// This is where I want to delete the row.
}
any help would be greatly appreciated.
If you have the range defined then use ADO.
--
Derek Davis dd******@gmail.com
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:Od**************@tk2msftngp13.phx.gbl...
I've tried that, but I keep getting "'object' does not contain a definition for 'EntireRow'".
"Denis Dougall" <De***********@here.there.com> wrote in message news:Ok*************@TK2MSFTNGP14.phx.gbl...
You can then iterate through and delete the empty cells/rows and preserve your formulae. However here is some delete row code.
Range(x,y ).EntireRow.Delete
Range(Cells(1, 1), Cells(99, ubound var)).EntireColumn.Delete
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:eu**************@TK2MSFTNGP11.phx.gbl...
I want to delete the entire row... I have a range of 1280 rows that I want to remove the duplicate rows... I'm not sure I understand how the "clear cell info" is going to help with that.
"Denis Dougall" <De***********@here.there.com> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl...
Check out this link http://msdn.microsoft.com/library/de...l/ExcelObj.asp . ANd you are looking for the clear cell info.
Cheers,
Denis
"Karl Richards" <kc**********@Hotmail.com> wrote in message news:ui*************@TK2MSFTNGP12.phx.gbl...
I am attempting to delete duplicate rows in a spreadsheet using the Excel object.
Does anyone have any idea how to do this? I've looked everywhere that I can find on the Web and have not been able to find anything on it.
What I have so far is:
Excel.Range range = oSheet.get_Range("A1", Type.Missing);
range = range.get_End(Excel.XlDirection.xlDown);
string downAddress = range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
range = oSheet.get_Range("A1",downAddress);
object[,] values = (object[,])range.Value2;
for (int i = 2; i < values.GetLength(0); i++)
{
if (values[i-1,1].ToString() == values[i,1].ToString())
{
// This is where I want to delete the row.
}
any help would be greatly appreciated.
Using Excel Macro record to record your action while you delete the row.
One the row is delete check how VBA is code to fullfill this task.
Then try the samething from your C#.
carion1 wrote: If you have the range defined then use ADO.
--
Derek Davis dd******@gmail.com <mailto:dd******@gmail.com>
"Karl Richards" <kc**********@Hotmail.com <mailto:kc**********@Hotmail.com>> wrote in message news:Od**************@tk2msftngp13.phx.gbl... I've tried that, but I keep getting "'object' does not contain a definition for 'EntireRow'".
"Denis Dougall" <De***********@here.there.com <mailto:De***********@here.there.com>> wrote in message news:Ok*************@TK2MSFTNGP14.phx.gbl... You can then iterate through and delete the empty cells/rows and preserve your formulae. However here is some delete row code.
Range(x,y ).EntireRow.Delete Range(Cells(1, 1), Cells(99, ubound var)).EntireColumn.Delete
Denis "Karl Richards" <kc**********@Hotmail.com <mailto:kc**********@Hotmail.com>> wrote in message news:eu**************@TK2MSFTNGP11.phx.gbl... I want to delete the entire row... I have a range of 1280 rows that I want to remove the duplicate rows... I'm not sure I understand how the "clear cell info" is going to help with that.
"Denis Dougall" <De***********@here.there.com <mailto:De***********@here.there.com>> wrote in message news:%2***************@TK2MSFTNGP12.phx.gbl... Check out this link http://msdn.microsoft.com/library/de...l/ExcelObj.asp . ANd you are looking for the clear cell info.
Cheers,
Denis
"Karl Richards" <kc**********@Hotmail.com <mailto:kc**********@Hotmail.com>> wrote in message news:ui*************@TK2MSFTNGP12.phx.gbl... I am attempting to delete duplicate rows in a spreadsheet using the Excel object.
Does anyone have any idea how to do this? I've looked everywhere that I can find on the Web and have not been able to find anything on it.
What I have so far is: Excel.Range range = oSheet.get_Range("A1", Type.Missing); range = range.get_End(Excel.XlDirection.xlDown); string downAddress = range.get_Address(false, false, XlReferenceStyle.xlA1, Type.Missing, Type.Missing);
range = oSheet.get_Range("A1",downAddress); object[,] values = (object[,])range.Value2;
for (int i = 2; i < values.GetLength(0); i++) { if (values[i-1,1].ToString() == values[i,1].ToString()) { // This is where I want to delete the row. }
any help would be greatly appreciated. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Powell |
last post by:
What would one best recommend to parse an existing Excel spreadsheet (was
done in Excel 97 or 2000 not sure to be honest)? I am looking for the most
practical way of parsing an existing...
|
by: Allison Bailey |
last post by:
Hi Folks,
I'm a brand new Python programmer, so please point me in the right
direction if this is not the best forum for this question....
I would like to open an existing MS Excel spreadsheet...
|
by: quadric |
last post by:
Hi,
I have an application that requires that Python initiate and mediate a live
and iterative conversation
between an external application (in which Python is embedded) and an
external Excel...
|
by: syvman |
last post by:
Hi everyone... I am pulling my hair out trying to do this, and was
wondering if someone could give me some assistance...
I have an Excel spreadsheet containing several worksheets. I'd like to
be...
|
by: Scott M. Lyon |
last post by:
I'm trying to figure out a way to export data (actually the result of a
Stored Procedure call from SQL Server) into a specified Excel spreadsheet
format.
Currently, I have the data read into a...
|
by: ssrirao |
last post by:
There is an Excel Spreadsheet containing data, residing in an internet site.
It’s very easy to Import data from a local Excel Spreadsheet into SQL Server Database Table using DTS.
But in my case...
|
by: Bill Atkins |
last post by:
I'd like to embed an Excel spreadsheet in my C# application.
The information I've found on the Web suggests placing a Web Browser
control on the form and navigating it to an Excel spreadsheet. ...
|
by: Sport Girl |
last post by:
Hi everybody ,
i have the task of developing in Perl a script that retrieves data from 3 tables ( bugs, profiles, products) from a MySQL database called bugs and display them in an excel sheet...
|
by: Maurita |
last post by:
Hi All, hope someone can lead me in the right direction. I am in new
territory and am unsure what to do after importing an Excel
Spreadsheet into my database.
1. The same spreadsheet with new...
|
by: Will |
last post by:
Can someone help with code to delete multiple columns from an excel
spreadsheet? I know which columns I need to delete. The code below will
delete a single column but I'm not sure how to delete...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |