Remember to update to the newest version of OfficeWriter! New updates are periodically released which include new features, tweaks to improve usability, and bug fixes to help make your OfficeWriter experience as productive as possible. |
Table of Contents |
---|
What might cause this to happen:
/* INCORRECT CODE: for (int i = 1; i < 50; i++) { ws.InsertRow(i + 5); ws.InsertColumn(i + 5); } */ |
Solutions:
// 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); |
What might cause this to happen:
/* INCORRECT CODE: ColumnProperties columnProperties; for (int i = 0; i < 3; i++) { columnProperties = ws.GetColumnProperties(i); columnProperties.AutoFitWidth(); } */ |
Why this method causes issues:
Solutions:
// POSSIBLE CORRECT CODE: DataTable dts = GetData(Page.MapPath(@"data\PersonsInfoV2.csv")); // Column on which the custom autofit starts, to be set by user. int startingColumn = 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 = 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 = 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.Columns.Count)&&(startingColumn < endColumn)) { // Find the size of the array, based on the starting location. longest = 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 = startingColumn; i < endColumn; i++) { // Find the temporary length of that row. temp = row[i].ToString().Length; // Is it the longest in the column so far? If yes, set it as such. (Longest subtracts startColumn from index to keep starting index at 0.) if (temp > longest[i-startingColumn]) { longest[i-startingColumn] = 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 = startingColumn; i < endColumn; i++) { ColumnProperties columnProperties; columnProperties = ws.GetColumnProperties(i); columnProperties.WidthInChars = longest[i-startingColumn]; } } |
What might cause this to happen:
Why this method causes issues:
Solutions:
View the information on performance issues that effect the amount of memory taken up by a report. Even if memory performance issues were your main concern, you may wish to view these fixes as well, as there tends to be some overlap between the categories.