Message-ID: <216905320.9517.1711692901444.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9516_1449599505.1711692901444" ------=_Part_9516_1449599505.1711692901444 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Table of Contents | =20
---|
=20 |
What might cause this to happen:
=20/* INCORRECT CODE: for (int i =3D 1; i < 50; i++) { ws.InsertRow(i + 5); ws.InsertColumn(i + 5); } */=20
Solutions:
=20// POSSIBLE CORRECT CODE: // Example inserting a single row and column to split up data. ws.InsertRow(1); ws.InsertColumn(1); // Example inserting multiple rows and columns to move data down. ws.InsertRows(0, 10); ws.InsertColumns(0, 10);=20
What might cause this to happen:
=20/* INCORRECT CODE: ColumnProperties columnProperties; for (int i =3D 0; i < 3; i++) { columnProperties =3D ws.GetColumnProperties(i); columnProperties.AutoFitWidth(); } */=20
Why this method causes issues:
=20Solutions:
=20// POSSIBLE CORRECT CODE: DataTable dts =3D GetData(Page.MapPath(@"data\PersonsInfoV2.csv")= ); // Column on which the custom autofit starts, to be set by user. int startingColumn =3D int.Parse(dts.Rows[0][9].ToString()); // Column on which the custom autofit ends, to be set by user. (Should be = set to the row AFTER the last column to be autofit.) int endColumn =3D int.Parse(dts.Rows[1][9].ToString()); // Array of the longest variables in each column. int[] longest; // Temporary variable for keeping track of current location int temp =3D 0; // The loop to check on the width of each column. Only start if the given = starting and ending places are valid. if ((startingColumn < dts.Columns.Count)&&(endColumn < dts.Co= lumns.Count)&&(startingColumn < endColumn)) { // Find the size of the array, based on the starting location. longest =3D new int[endColumn - startingColumn]; // For each row in the DataTable... foreach (DataRow row in dts.Rows) { // For each column, based on that row... for (int i =3D startingColumn; i < endColumn; i++) { // Find the temporary length of that row. temp =3D row[i].ToString().Length; // Is it the longest in the column so far? If yes, set it as s= uch. (Longest subtracts startColumn from index to keep starting index at 0= .) if (temp > longest[i-startingColumn]) { longest[i-startingColumn] =3D temp; } } } // After looping through, set the width of each column to the longest. // You can change this function to change where in the output file for (int i =3D startingColumn; i < endColumn; i++) { ColumnProperties columnProperties; columnProperties =3D ws.GetColumnProperties(i); columnProperties.WidthInChars =3D longest[i-startingColumn]; } }=20
What might cause this to happen:
=20Why this method causes issues:
=20Solutions:
=20View the info= rmation on performance issues that effect the amount of memory taken up by = a report. Even if memory performance issues were your main concer= n, you may wish to view these fixes as well, as there tends to be some over= lap between the categories.