The example in this article describes how C # controls Excel sheet The way it adapts to page width and column width. Share to everyone for your reference, specific as follows:
<summary>///1.Clear circlereference///2.Set Page to fit Wide///3.Set Column Text fit///</SUMMARY&G
T <param name= "App" ></param>///<param name= "ws" ></param> private void Worksheetpageset (
Microsoft.Office.Interop.Excel.Application app, worksheet ws) {clearcirclereference (WS);
Setpagetofitwide (WS);
Setcolumnfit (WS); /////<summary>///Set Column Text fit///</summary>///<param name= "sheet" ></param> private
static void Setcolumnfit (worksheet sheet) {Char column = ' B '; for (int i = 0; i < i++) {Range range = Sheet.get_range (String.Format ("{0}1", column). ToString ()), String.Format ("{0}1", column).
ToString ())); if (range!= null) {range.
Entirecolumn.autofit ();
} column++; }/////<summary>///clear circlereference///</summary>///<param name= "sheet" >worksheet object< ;/param> private void clearcirclereference (worksheet sheet) {Range range = sheet. CiRcularreference; while (range!= null) {range.
Clear (); Range = Sheet.
Circularreference; }/////<summary>///Set Page to fit Wide///</summary>///<param name= "ws" >worksheet ram> private static void setpagetofitwide (worksheet ws) {ws.
Pagesetup.zoom = false; Ws.
Pagesetup.fittopageswide = 1; Ws.
Pagesetup.fittopagestall = false;
}
Read more about C # Interested readers can view the site topics: "C # Operations Excel Skills Summary", "C # XML file Operation Tips Summary", "C # Common control usage Tutorial", "WinForm Control Usage Summary", "C # Data structure and algorithm tutorial", "C # An introductory course on object-oriented programming and a summary of thread usage tips for C # programming
I hope this article will help you with C # programming.