c# - VSTO: Don't inlcude column header -
i'm using vsto bring data database , displaying on worksheet
the user presses button , worksheet gets populated data
the problem when data gets written worksheet automatically includes column header, don't want column header
i set listobject.showheaders = false;
includes empty cell, don't want empty cell.
this how declare listobject
private void createlistobject() { worksheet = (excel.worksheet)this.application.activeworkbook.worksheets[1]; worksheet extendedworksheet = globals.factory.getvstoobject(worksheet); excel.range cell = extendedworksheet.range["c12", "c16"];//obtain range this.listobject = extendedworksheet.controls.addlistobject(cell, "data");//add listobject this.listobject.autosetdataboundcolumnheaders = false; this.listobject.showautofilter = false; this.listobject.showheaders = false; //i thought enough this.listobject.showtablestylerowstripes = false; }
this how populate data
internal void displaydata() { try { using (mydbcontext db = new mydbcontext ()) { list<thing> things= db.things.tolist(); createlistobject(); string[] mappedcolumns = { "serialnumber" }; this.listobject.setdatabinding(things, string.empty, mappedcolumns); } } catch (exception ex) { messagebox.show(ex.message); } }
but when data gets displayed, includes empty cell:
how avoid column header?
i afraid headers
of listobject
in excel can't removed. can convert listobject
range
, delete first row.
range rng; rng = this.listobject.range; this.listobject.unlist(); rng.rows[0].delete();
Comments
Post a Comment