更改excel的格式会将文件转换为疯狂的大小

时间:2015-08-20 22:10:46

标签: excel vba excel-vba

我只是使用vba代码更改工作表的格式,文件变得非常大,增加了~200 MB。如果我使用excel接口,不会发生这种情况,但我想使用代码。

Function ReturnName(ByVal num As Integer) As String
    ReturnName = Split(Cells(, num).Address, "$")(1)
End Function     

lcol = ws1.Cells(1, ws1.Columns.Count).End(xlToLeft).Column
For i = 1 To lcol
If (ws1.Cells(4, i) = "Date") Then
ws1.Range(ReturnName(i) & "5" & ":" & ReturnName(i) & "1000").NumberFormat = "yyyy-mm-dd"
Else
ws1.Range(ReturnName(i) & "5" & ":" & ReturnName(i) & "1000").NumberFormat = "0"
End If
Next i

1 个答案:

答案 0 :(得分:2)

试试这个例子:

    (function($) {
    "use strict";
    function positionModals(e) {
        var $this = $(this).css('display', 'block'),
            $window = $(window),
            $dialog = $this.find('.modal-dialog'),
            offset = ($window.height() - $window.scrollTop() - $dialog.height()) / 2,
            marginBottom = parseInt($dialog.css('margin-bottom'), 10);

        $dialog.css('margin-top', offset < marginBottom ? marginBottom : offset);
    }

    $(document).on('show.bs.modal', '.modal', positionModals);

    $(window).on('resize', function(e) {
        $('.modal:visible').each(positionModals);
    });
    }(jQuery));