|
|
 |
专题栏目 |
 |
 |
相关文章 |
 |
|
|
|
|
 |
T-SQL 存储过程创建 PDF 格式文件(报表) |
热 |
|
| T-SQL 存储过程创建 PDF 格式文件(报表) |
|
作者:playyuer 文章来源:不详 点击数: 更新时间:2007-11-14 12:01:11  |
|
| '' '''' + @a2 + '''' /ProcSet [ /'''' + CHAR(80) + CHAR(68) + CHAR (70) + '''' /Text ]'''')
INSERT INTO #pdf (code) VALUES (@a2)
INSERT INTO #pdf (code) VALUES (@end)
INSERT INTO #text(code) (SELECT code FROM psopdf)
SELECT @x = COUNT(*) FROM #text
SELECT @x = (@x / 60) + 1
WHILE @nopg < @x
BEGIN
DECLARE SysKursor INSENSITIVE SCROLL CURSOR
FOR SELECT SUBSTRING((code + SPACE(81)), 1, 80) FROM #text WHERE idnumber BETWEEN ((@nopg * 60) + 1) AND ((@nopg + 1) * 60 )
FOR READ ONLY
OPEN SysKursor
FETCH NEXT FROM SysKursor INTO @trenutniRed
SELECT @object = @object + 1
SELECT @page = @page + '''' '''' + CAST(@object AS VARCHAR) + @ad
SELECT @len = LEN(@object) + LEN(@object + 1)
INSERT INTO #pdf (code) VALUES (CAST(@object AS VARCHAR) + @beg)
INSERT INTO #pdf (code) VALUES (@a1)
INSERT INTO #pdf (code) VALUES (''''/Type /Page'''')
INSERT INTO #pdf (code) VALUES (''''/Parent 3'''' + @ad)
INSERT INTO #pdf (code) VALUES (''''/Resources 6'''' + @ad)
SELECT @object = @object + 1
INSERT INTO #pdf (code) VALUES (''''/Contents '''' + CAST(@object AS VARCHAR) + @ad)
INSERT INTO #pdf (code) VALUES (@a2)
INSERT INTO #pdf (code) VALUES (@end)
SELECT @ofset = @len + 86 + @ofset
INSERT INTO #xref(code) (SELECT SUBSTRING(''''0000000000'''' + CAST(@ofset AS VARCHAR),
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR)) - 9,
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR))) + @xstr)
INSERT INTO #pdf (code) VALUES (CAST(@object AS VARCHAR) + @beg)
INSERT INTO #pdf (code) VALUES (@a1)
SELECT @object = @object + 1
INSERT INTO #pdf (code) VALUES (''''/Length '''' + CAST(@object AS VARCHAR) + @ad)
INSERT INTO #pdf (code) VALUES (@a2)
INSERT INTO #pdf (code) VALUES (''''stream'''')
INSERT INTO #pdf (code) VALUES (''''BT'''')
INSERT INTO #pdf (code) VALUES (''''/F1 10 Tf'''')
INSERT INTO #pdf (code) VALUES (''''1 0 0 1 50 802 Tm'''')
INSERT INTO #pdf (code) VALUES (''''12 TL'''')
WHILE @@Fetch_Status = 0
BEGIN
INSERT INTO #pdf (code) VALUES (''''T* ('''' + @trenutniRed + '''') Tj'''')
FETCH NEXT FROM SysKursor INTO @trenutniRed
END
INSERT INTO #pdf (code) VALUES (''''ET'''')
INSERT INTO #pdf (code) VALUES (''''endstream'''')
INSERT INTO #pdf (code) VALUES (@end)
SELECT @rows = (SELECT COUNT(*) FROM #text WHERE idnumber BETWEEN ((@nopg * 60) + 1) AND ((@nopg + 1) * 60 ))* 90 + 45
SELECT @nopg = @nopg + 1
SELECT @len = LEN(@object) + LEN(@object - 1)
SELECT @ofset = @len + 57 + @ofset + @rows
INSERT INTO #xref(code) (SELECT SUBSTRING(''''0000000000'''' + CAST(@ofset AS VARCHAR),
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR)) - 9,
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR))) + @xstr)
INSERT INTO #pdf (code) VALUES (CAST(@object AS VARCHAR) + @beg)
INSERT INTO #pdf (code) VALUES (@rows)
INSERT INTO #pdf (code) VALUES (@end)
SELECT @len = LEN(@object) + LEN(@rows)
SELECT @ofset = @len + 18 + @ofset
INSERT INTO #xref(code) (SELECT SUBSTRING(''''0000000000'''' + CAST(@ofset AS VARCHAR),
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR)) - 9,
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR))) + @xstr)
CLOSE SysKursor
DEALLOCATE SysKursor
END
INSERT INTO #pdf (code) VALUES (''''2'''' + @beg)
INSERT INTO #pdf (code) VALUES (@a1)
INSERT INTO #pdf (code) VALUES (''''/Type /Catalog'''')
INSERT INTO #pdf (code) VALUES (''''/Pages 3'''' + @ad)
INSERT INTO #pdf (code) VALUES (''''/PageLayout /OneColumn'''')
INSERT INTO #pdf (code) VALUES (@a2)
INSERT INTO #pdf (code) VALUES (@end)
UPDATE #xref SET code = (SELECT code FROM #xref WHERE idnumber = (SELECT MAX(idnumber) FROM #xref)) WHERE idnumber = 5
DELETE FROM #xref WHERE idnumber = (SELECT MAX(idnumber) FROM #xref)
INSERT INTO #pdf (code) VALUES (''''3'''' + @beg)
INSERT INTO #pdf (code) VALUES (@a1)
INSERT INTO #pdf (code) VALUES (''''/Type /Pages'''')
INSERT INTO #pdf (code) VALUES (''''/Count '''' + CAST(@nopg AS VARCHAR))
INSERT INTO #pdf (code) VALUES (''''/MediaBox [ 0 0 595 842 ]'''')
INSERT INTO #pdf (code) VALUES (''''/Kids ['''' + @page + '''' ]'''')
INSERT INTO #pdf (code) VALUES (@a2)
INSERT INTO #pdf (code) VALUES (@end)
SELECT @ofset = @ofset + 79
UPDATE #xref SET code =(SELECT SUBSTRING(''''0000000000'''' + CAST(@ofset AS VARCHAR),
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR)) - 9,
LEN(''''0000000000'''' + CAST(@ofset AS VARCHAR))) + @xstr) WHERE idnumber = 6
INSERT INTO #xref(code) VALUES (''''trailer'''')
INSERT INTO #xref(code) VALUES (@a1)
SELECT @object = @object + 1
UPDATE #xref SET code = ''''0 '''' + CAST(@object AS VARCHAR) WHERE idnumber = 2
INSERT INTO #xref(code) VALUES (''''/Size '''' + CAST(@object AS VARCHAR))
INSERT INTO #xref(code) VALUES (''''/Root 2'''' + @ad)
INSERT INTO #xref(code) VALUES (''''/Info 1'''' + @ad)
INSERT INTO #xref(code) VALUES (@a2)
INSERT INTO #xref(code) VALUES (''''startxref'''')
SELECT @len = LEN(@nopg) + LEN(@page)
SELECT @ofset = @len + 86 + @ofset
INSERT INTO #xref(code) VALUES (@ofset)
INSERT INTO #xref(code) VALUES (''''%%'''' + CHAR(69) + CHAR (79) + CHAR(70))
INSERT INTO #pdf (code) (SELECT code FROM #xref)
--SELECT code FROM #pdf
SELECT @trenutniRed = ''''del ''''+ @pdf
EXECUTE @ole = sp_OACreate ''''Scripting.FileSystemObject'''', @fs OUT
EXEC master..xp_cmdshell @trenutniRed, NO_OUTPUT
EXECUTE @ole = sp_OAMethod @fs, ''''OpenTextFile'''', @file OUT, @pdf, 8, 1
DECLARE SysKursor INSENSITIVE SCROLL CURSOR
FOR SELECT code FROM #pdf ORDER BY idnumber
FOR READ ONLY
OPEN SysKursor
FETCH NEXT FROM SysKursor INTO @trenutniRed
WHILE @@Fetch_Status = 0
BEGIN
EXECUTE @ole = sp_OAMethod @file, ''''WriteLine'''', Null, @trenutniRed
FETCH NEXT FROM SysKursor INTO @trenutniRed
END
CLOSE SysKursor
DEALLOCATE SysKursor
DELETE FROM psopdf
EXECUTE @ole = sp_OADestroy @file
EXECUTE @ole = sp_OADestroy @fs
上一页 [1] [2] |
|
| 文章录入:mintao 责任编辑:mintao |
|
|
上一篇文章: 关于日期的sql,做报表的时候可能有用!!! 下一篇文章: RS.OPEN SQL,CONN,A,B 全接触! |
|
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网] |
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| |
|
|
|
|