public static void ExportData()
{
Microsoft.Office.Interop.Excel.Application xlexcel;
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlexcel = new Excel.Application();
xlexcel.Visible = true;
xlWorkBook = xlexcel.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkBook.Application.ScreenUpdating = false;
Excel.Range CR = (Excel.Range)xlWorkSheet.Cells[1, 1];
CR.Select();
xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true);
Excel.Range DR = (Excel.Range)xlWorkSheet.Columns["A:A"];
DR.Select();
DR.Delete();
Excel.Range A1 = (Excel.Range)xlWorkSheet.Cells[1, 1];
A1.Select();
}
This is the current function that I have. In the end, I would like to reproduce this VB code from Excel, which I have;
Columns("A:A").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
I tried several different options, replacing "Selection", but the closest I had C # to select empty cells, but then it will delete ALL, not just the selected text.
Does anyone have a direction I can go?
Also using
using Excel = Microsoft.Office.Interop.Excel;
source
share