关于winform中的Excel报告 [英] Regarding Excel Report in winform

查看:78
本文介绍了关于winform中的Excel报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,任何人都可以吸我。



我正在使用sql函数填写excel中的日期和日期



在我的用户界面中,我有从日期和到目的地。

2013年4月1日 - >从即日起

2013年4月30日 - >到期日



Excel报告



日期日

1-03-13周一



2-03-13周二

3 -03-13星期三



15-03-13星期二

..

30-03- 13星期二



这里的日计算我把它制成了excel sheet公式本身。



= TEXT(A1, dddd)



在我的excel表格中,我将该公式硬编码了31天它是静态的



但是我的用户界面他可能选择不到31天



即1-3-12到15-3-12



所以我的excel表日专栏在15-03-13之后所有周六,周六只有



如何解决这个问题。 />


错误结果:

日期日

1-03-13星期一



2-03-13星期二

3-03-13星期三


15-03-13星期二

星期六

星期六

星期六

预期成果

日期日

1-03-13周一



2-03 -13星期二

3-03-13星期三



15-03-13星期二

Hi guys any one can sugest me.

I''m using sql functions to fill date and day in the excel

In my user interface i have From date and To date.
1 April 2013--> From Date
30 April 2013-->To Date

Excel Report

Date Day
1-03-13 Monday

2-03-13 Tuesday
3-03-13 Wednesday
.
15-03-13 Tuesday
..
30-03-13 Tuesday

Here day calculation i made it excel sheet formula itself.

=TEXT(A1, "dddd")

In My excel sheet i hard coded the formula for 31 days it is static

But i my user interface he may select less than 31 days

i.e 1-3-12 to 15-3-12

So i my excel sheet Day column after 15-03-13 all coming Saturday,Saturday only

How to solve this problem.

Bug Result:
Date Day
1-03-13 Monday

2-03-13 Tuesday
3-03-13 Wednesday
.
15-03-13 Tuesday
Saturday
Saturday
Saturday
Expected Result
Date Day
1-03-13 Monday

2-03-13 Tuesday
3-03-13 Wednesday
.
15-03-13 Tuesday

推荐答案

改为使用白天和添加功能:

http://msdn.microsoft.com/en-us/library/system.datetime.add.aspx [ ^ ]
Use daytime and the add function instead:
http://msdn.microsoft.com/en-us/library/system.datetime.add.aspx[^]


Excel(VBA):

Excel (VBA):
Sub EnumDates()

Dim curDate As Date, fromDate As Date, toDate As Date
Dim i As Integer

i = 1
fromDate = DateSerial(2013, 1, 1)
toDate = DateSerial(2013, 3, 31)
curDate = fromDate - 1
Do While curDate < toDate
    curDate = curDate + 1
    With ThisWorkbook.Worksheets(1).Range("A" & i)
        .NumberFormat = "yyyy-MM-dd"
        .Value = curDate
    End With
    With ThisWorkbook.Worksheets(1).Range("B" & i)
        .NumberFormat = "dddd"
        .Value = curDate
    End With
    i = i + 1
Loop

End Sub









SQL:





SQL:

DECLARE @curDate DATETIME
DECLARE @fromDate DATETIME
DECLARE @toDate DATETIME

SET @fromDate = '2013-01-01'
SET @toDate = '2013-03-31'
SET @curDate = @fromDate -1
;WITH dates AS
(
	SELECT @curDate +1 As MyDate, DATENAME(dw, @curDate +1) AS MyDayName
	UNION ALL
	SELECT MyDate +1, DATENAME(dw, MyDate +1) AS MyDayName
	FROM dates
	WHERE MyDate<@toDate	
)
SELECT *
FROM dates


这篇关于关于winform中的Excel报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆