473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problem with inserting rows/range in excel

Hello,

I am writing a little application which uses a template excel file and
adds some information and then stores the changed file.

The problem is, i don't really know how to add these rows - row by
row. I can insert a range, but when I insert a range the data that is
written below that isn't shifted down like I ment it would/should.

Here is some sample code:

object[,] objData = new Object[strColumns.Length,1];
for (int i = 0; i < strColumns.Length; i++)
{
DataColumnCollection dcc =
myDataSet.AM.Columns;
foreach (DataColumn dc in dcc)
{
if (dc.ColumnName == strColumns[i])
{
objData[i, 0] = "A: " + strColumns[i]
+ " " +
myAMRow.ItemArray[myDataSet.AM.Columns.IndexOf(dc.ColumnName)];
}
}
}
m_objRange = myOverviewWorksheet.get_Range("C" +
(iZeile1+3).ToString(), "C" +
(iZeile1+3+strColumns.Length).ToString());
m_objRange =
m_objRange.get_Resize(strColumns.Length,1);
m_objRange.set_Value(missing, objData);
theWorkbook.SaveAs(strFilePath + "\\" +
myRow.PRONAME + "_" + myAMRow.APNUMMER, missing, missing,
missing, missing, missing, Excel.XlSaveAsAccessMode.xlNoChange,
missing, missing, missing, missing, missing);
theWorkbook.Close(false, missing, missing);
ExcelObj.Quit();

but what I actually want it something like that:

for (int i = 0; i < strColumns.Length; i++)
{
DataColumnCollection dcc =
myDataSet.AM.Columns;
foreach (DataColumn dc in dcc)
{
if (dc.ColumnName == strColumns[i])
{
// insert 3 rows into the worksheet
// row1: A: dc.ColumnName
// row2: myAMRow.column
// row3:
myOverviewWorksheet.insert(rows,
shift down);

}
}
}
theWorkbook.SaveAs(strFilePath + "\\" +
myRow.PRONAME + "_" + myAMRow.APNUMMER, missing, missing,
missing, missing, missing, Excel.XlSaveAsAccessMode.xlNoChange,
missing, missing, missing, missing, missing);
theWorkbook.Close(false, missing, missing);
ExcelObj.Quit();

but somehow I can't get that idea running!!

help, please ;-)

Greetings
Chris

Mar 5 '07 #1
0 1398

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ImraneA | last post by:
Hi there Have a database, where front-end interface allows user to select a ms access database. From there, standard tables are linked. Routine, that creates a spreadsheet, for each table a...
1
by: barma16 | last post by:
I've hit a bit of a brick wall here, and could use some advice. I have an Access application whose output is a four-tab Excel spreadsheet where three of the four tabs are the result of database...
2
by: toddmoses26 | last post by:
I've got code that builds a DAO recordset from a table, and then pastes the recorset in a specified area in an Excel worksheet. *************************************************** Function...
1
by: RickH | last post by:
..Cells(1,y).GetType ownly shows instead of .Value, .Copy, etc. The code below is derived from samples, it should work, but I've messed up somewhere... Imports System.Windows.Forms Imports...
0
by: sysmanint1 | last post by:
I am a total neophyte at Visual Basic but found the following post and reply from Clint concerning a dynamic range. Also, have never "posted" to a discussion I have made a macro that works on...
6
by: grego9 | last post by:
I am trying to write some code to get Excel 2000 to insert a blank row wherever there is a "NO" in column O (above the NO). The code below nearly does this - but not quite!. The problem I have is...
0
by: eBob.com | last post by:
Here's how I insert and size pictures in an Excel spreadsheet which I create via a VB.NET program (commentary follows): 'add thumb nail objSheet.Rows(XLRow.ToString).rowheight =...
11
by: poolboi | last post by:
hi guys, below is a script that i need yr help on i got this to print out a csv to excel i'm trying to modify it to read a .txt file to convert an excel hm...doesn't seem to work still any idea...
1
by: evenlater | last post by:
I have an Excel workbook that I'm programming from Access. The rows in the workbook vary in height. So let's say row 8 is taller than the rows above it. If I *manually* insert 2 new rows at the...
0
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$) { } ...
0
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
Oralloy
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,...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.