Skip to content

Commit

Permalink
removecloumns
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Yang <yangbo.game@gmail.com>
  • Loading branch information
Henry Yang committed Apr 12, 2012
1 parent 194a6e0 commit 1b69ee4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
4 changes: 4 additions & 0 deletions ExcelApplication/ExcelApplication/ExcelApplication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<PropertyGroup>
<ApplicationIcon>a3.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject>
</StartupObject>
</PropertyGroup>
<ItemGroup>
<Reference Include="EPPlus, Version=3.0.0.2, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
29 changes: 16 additions & 13 deletions ExcelApplication/ExcelApplication/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;
using Microsoft.Office.Interop.Excel;
using System.Reflection;

namespace ExcelApplication
{
Expand All @@ -15,19 +17,19 @@ public Form1()

public static List<string> GetSheetNames(string path)
{
List<string> ary = new List<string>();
Object missing = System.Reflection.Missing.Value;
Microsoft.Office.Interop.Excel._Application exc = new Microsoft.Office.Interop.Excel.Application();
exc.Visible = false;
Microsoft.Office.Interop.Excel.Workbooks workbooks = exc.Workbooks;
List<string> sheets = new List<string>();
Object missing = Missing.Value;
_Application excel = new Microsoft.Office.Interop.Excel.Application();
excel.Visible = false;
Workbooks workbooks = excel.Workbooks;
workbooks._Open(path, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
for (int i = 0; i < exc.Worksheets.Count; i++)
for (int i = 0; i < excel.Worksheets.Count; i++)
{
Microsoft.Office.Interop.Excel.Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)exc.Worksheets.get_Item(i + 1);
ary.Add(sheet.Name.ToString());
Worksheet sheet = (Worksheet)excel.Worksheets.get_Item(i + 1);
sheets.Add(sheet.Name.ToString());
}
exc.Application.Quit();
return ary;
excel.Application.Quit();
return sheets;
}

public bool dataTotal(int col)
Expand All @@ -39,11 +41,12 @@ public bool dataTotal(int col)
int columnCount = dataGridView1.ColumnCount;
int rowCount = dataGridView1.RowCount;

int total = 0;
string tempA = (string)dataGridView1.Rows[rowCount - 2].Cells[col].Value;
string tempB;
int total = 0;
for (int i = rowCount - 3; i >= 0; i--)
{
string tempB = (string)dataGridView1.Rows[i].Cells[col].Value;
tempB = (string)dataGridView1.Rows[i].Cells[col].Value;
if (tempA.GetHashCode() == tempB.GetHashCode())
{
for (int j = 6; j < columnCount; j++)
Expand Down Expand Up @@ -222,7 +225,7 @@ private void removeColumnToolStripMenuItem_Click(object sender, EventArgs e)
int rowCount = dataGridView1.RowCount;
string[] rowValue = new string[rowCount];

if (columnCount > 66)
if (columnCount > 50)
{
for (int i = columnCount - 1; i > 49; i--)
{
Expand Down

0 comments on commit 1b69ee4

Please sign in to comment.