Hi @irahmanJS6UB,
I save my data as a csv file, then use that. I find it easier than having references to Excel.
I have just grabbed some code from a project of mine, to give you an idea of what you need to do.
using (Transaction tr = db.TransactionManager.StartTransaction())
{
PromptSelectionResult blocks = null;
using (FileStream fs = new FileStream(csvFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
List<string[]> lines = new List<string[]>();
using (StreamReader sr = new StreamReader(fs))
{
do
{
string line = sr.ReadLine();
if (line == null)
{
ed.WriteMessage("The drawing register csv file '{0}' does not have any data.\nTitle blocks have not been updated. Please check register and try again.", csvFile);
return;
}
string[] entries = line.Split(',');
//lines.Add(entries);
lines.Add(ValidateLine(entries));
count++;
}
while (!sr.EndOfStream);
}
string[] attTags = lines[0];
AcApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nUpdating title block\n");
foreach (string s in getLayoutNames(db, tr))
{
blocks = getBlocksInLayout(tr);// s, tr);
if (blocks.Status == PromptStatus.OK)
{
foreach (ObjectId id in blocks.Value.GetObjectIds())
{
BlockReference br = (BlockReference)tr.GetObject(id, OpenMode.ForRead);
LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
LayerTableRecord ltr = (LayerTableRecord)tr.GetObject(lt[br.Layer], OpenMode.ForWrite);
bool locked = ltr.IsLocked;
ltr.IsLocked = false;
if (br.AttributeCollection.Count > 0)
{
br.UpgradeOpen();
foreach (ObjectId attId in br.AttributeCollection)
{
AttributeReference attref = (AttributeReference)tr.GetObject(attId, OpenMode.ForWrite);
if (attref != null)
{
bool drawingFound = false;
for (int i = 1; i < lines.Count; i++)
{
string[] entry = lines[i];
if (docName.Equals(entry[0], StringComparison.OrdinalIgnoreCase))
{
found = true;
for (int j = 0; j < attTags.Length; j++)
{
if (attref.Tag.Equals(attTags[j], StringComparison.OrdinalIgnoreCase))
{
if (attref.TextString != entry[j])
{
attref.TextString = entry[j];
ed.WriteMessage("\n{0} updated to {1}", attref.Tag, attref.TextString);
}
}
}
drawingFound = true;
break;
}
if (drawingFound) break;
}
}
}
}
ltr.IsLocked = locked;
}
}
if (!found)
{
AcApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nCould not find {0} in register\n", docName);
}
}
}
ed.SetImpliedSelection(new ObjectId[] { });
tr.Commit();
ed.Regen();
}
Hope this helps