コード例 #1
0
        public void SetColumnsWidths(double[] colWidths)
        {
            var colName = "A";

            foreach (var width in colWidths)
            {
                _writer.SetColumnWidth(colName, width);
                colName = SpreadsheetReader.GetColumnName(colName, 1);
            }
        }
コード例 #2
0
        public void WorksheetColumnWidthTest()
        {
            MemoryStream        stream        = SpreadsheetReader.Create();
            SpreadsheetDocument doc           = SpreadsheetDocument.Open(stream, true);
            WorksheetPart       worksheetPart = SpreadsheetReader.GetWorksheetPartByName(doc, "Sheet1");

            WorksheetWriter writer = new WorksheetWriter(doc, worksheetPart);

            writer.FindColumn("A").Width = 20;
            writer.FindColumn(2).Width   = 20;
            writer.SetColumnWidth("C", 20);

            //Save to the memory stream, and then to a file
            SpreadsheetWriter.Save(doc);
            SpreadsheetWriter.StreamToFile(string.Format("{0}\\columnwidths.xlsx", GetOutputFolder()), stream);
        }