❶ 列印網頁頁面,但是列印出了網頁的源代碼,列印預覽也是顯示源代碼。怎麼列印網頁本來的啊
碰到一個問題一樣,就是windows 7 64位操作系統,但是列印空白,列印出來像白紙一樣!經過查看和總結,確認是:由於保護模式下 %Temp%\Low 文件夾工作不正常引起的!故障列印白紙下面會出現類似:C:\Users\\AppData\Local\Temp\Low\xxxx.htm這樣的網頁。
原因:這種情況,多半由於保護模式下 %Temp%\Low 文件夾工作不正常引起的(被誤刪除、移位等等)
解決方法:
(1)重置IE安全級別
(2)在用戶模式下,在附件中找到cmd創建low文件,具體命令如下
mkdir %userprofile%\AppData\Local\Temp\Low
ICACLS "%userprofile%\AppData\Local\Temp\Low" /setintegritylevel (OI)(CI)low
如果用戶具有管理員許可權,請把以下代碼保存為bat批處理文件運行:
@ECHO off
If not exist %userprofile%\AppData\Local\Temp\Low (
echo.
echo Creating Low Folder...
mkdir %userprofile%\AppData\Local\Temp\Low
)
echo.
echo Apply Integrity Level...
echo.
ICACLS "%userprofile%\AppData\Local\Temp\Low" /setintegritylevel (OI)(CI)low
exit
總結:這個解決方法可能不是萬能的,可能只是針對某些故障的特定方法,不一定適用所有情況,不過也是一個考慮的方向和排除故障的考慮范圍。
❷ 誰有java列印的源代碼
//參考下吧
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.print.*;
import java.util.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.swing.*;
/**
This program demonstrates how to print 2D graphics
*/
public class PrintTest
{
public static void main(String[] args)
{
JFrame frame = new PrintTestFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
/**
This frame shows a panel with 2D graphics and buttons
to print the graphics and to set up the page format.
*/
class PrintTestFrame extends JFrame
{
public PrintTestFrame()
{
setTitle("PrintTest");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
canvas = new PrintPanel();
add(canvas, BorderLayout.CENTER);
attributes = new HashPrintRequestAttributeSet();
JPanel buttonPanel = new JPanel();
JButton printButton = new JButton("Print");
buttonPanel.add(printButton);
printButton.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
try
{
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(canvas);
if (job.printDialog(attributes))
job.print(attributes);
}
catch (PrinterException e)
{
JOptionPane.showMessageDialog(PrintTestFrame.this, e);
}
}
});
JButton pageSetupButton = new JButton("Page setup");
buttonPanel.add(pageSetupButton);
pageSetupButton.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
PrinterJob job = PrinterJob.getPrinterJob();
job.pageDialog(attributes);
}
});
add(buttonPanel, BorderLayout.NORTH);
}
private PrintPanel canvas;
private PrintRequestAttributeSet attributes;
private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_HEIGHT = 300;
}
/**
This panel generates a 2D graphics image for screen display
and printing.
*/
class PrintPanel extends JPanel implements Printable
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
drawPage(g2);
}
public int print(Graphics g, PageFormat pf, int page)
throws PrinterException
{
if (page >= 1) return Printable.NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D) g;
g2.translate(pf.getImageableX(), pf.getImageableY());
g2.draw(new Rectangle2D.Double(0, 0, pf.getImageableWidth(), pf.getImageableHeight()));
drawPage(g2);
return Printable.PAGE_EXISTS;
}
/**
This method draws the page both on the screen and the
printer graphics context.
@param g2 the graphics context
*/
public void drawPage(Graphics2D g2)
{
FontRenderContext context = g2.getFontRenderContext();
Font f = new Font("Serif", Font.PLAIN, 72);
GeneralPath clipShape = new GeneralPath();
TextLayout layout = new TextLayout("Hello", f, context);
AffineTransform transform = AffineTransform.getTranslateInstance(0, 72);
Shape outline = layout.getOutline(transform);
clipShape.append(outline, false);
layout = new TextLayout("World", f, context);
transform = AffineTransform.getTranslateInstance(0, 144);
outline = layout.getOutline(transform);
clipShape.append(outline, false);
g2.draw(clipShape);
g2.clip(clipShape);
final int NLINES =50;
Point2D p = new Point2D.Double(0, 0);
for (int i = 0; i < NLINES; i++)
{
double x = (2 * getWidth() * i) / NLINES;
double y = (2 * getHeight() * (NLINES - 1 - i))
/ NLINES;
Point2D q = new Point2D.Double(x, y);
g2.draw(new Line2D.Double(p, q));
}
}
}
❸ 用C語言實現列印功能的具體代碼是什麼
列印,這是個大的概念
你要指明你要列印到哪裡
一般的「列印」值輸出到標準的輸出設備(CRT)
如果需要「列印」到其他設備,可以用流的重定向解決這個問題
標準的I/O頭文件是stdio.h,裡面聲明了大部分I/O函數,你可以在那裡查閱
滿意請採納,不滿意請追問
❹ 學生信息管理系統最簡單源代碼。
方法一:
1、創建一個c語言項目。然後右鍵頭文件,創建一個Stu的頭文件。
❺ 怎麼查看安卓源碼中的列印信息
編譯的時候在終端中一開始就會列印出來
❻ c語言 可以查詢近5年的信息的源代碼
都世界末日了 兄弟就別交了吧!
工資.txt有啥格式要求不! 沒有話你就可以這樣寫
[2012] 50000 55354
[2011] 45000 45824
[2010] 40002 42563
[2009] 15748 16333
[2008] 35718 36999
要查詢2009 那麼就寫個query(2009)
query(int year )
{
FILE *fd = open("xxx.txt", r);
char buf[1024] = {0};
char years[] = itoa(year);
strcat(years , "]"); //把 2009 變成 「2009]」
fread(buf , 1, 1024 , fd); //那工資全部讀出來
char *p = strstr(years , buf); //在buf中找到 2009]」的位置
while(*(p++) != ']')
;//定位到[2009]後面的那個字元
while(*p == ' ')
{
p++;
}//過濾掉[2009]空格
char salary1[10] ;
while ( *p != ' ')
{
*salary1++ = *p++;
}
int s1 = atio(salary //後面的參數不記得了);//得到稅前工資
while(*p == ' ')
{
p++;
}//過濾掉sarary1後面的空格
char salary1[10] ;
while ( *p != ' ')
{
*salary2++ = *p++;
}
int s2 = atio(salary //後面的參數不記得了);//得到稅前工資
} //大概思路是這樣的 , 自己再改改就OK了 細節我就沒有注意了
怎麼把s1 s2傳出去就是你的事了
❼ C++ 列印源代碼(控制台)
我有一個C語言的
main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}
可以把自己列印出來
C++ 不知道有沒有類似的
❽ 怎樣列印程序源代碼
網頁的是: 查看=》源文件 會出現一個記事本文件,然後列印吧
❾ 求ASP操作excel資料庫 功能實現查看,修改,統計,列印等等,源碼或者模塊,成分感謝!
摘 要 主要介紹用Excel做資料庫並使用ASP編程對其進行操作
關鍵詞 ASP,Excel,編程,資料庫
一、 問題的提出
在ASP編程中會遇到很多大大小小的難題,我有一次為一家書店設計網站的時候就遇到了一個這樣的難題。起初使用Access做資料庫,該資料庫主要是為了保存書店內圖書的信息,但是當記錄的條目過多時資料庫的體積將會變得很大。在實際的應用中,網站的空間是有限的,很多要建設網站的客戶都沒有自己的主機,網站的空間是向網站空間提供商花錢購買而來的,這就要求在網站空間一定的條件下,盡量減小網站內文件的體積。於是我選擇了Excel做資料庫。
二、 方法與說明
將Excel文件(例如book.xls)看成一個資料庫,其中的每一個工作表(sheet)看成資料庫表。假設Excel中的第一行為欄位名,所以你定義的范圍中必須要包括第一行的內容。
Excel中的行標題(即欄位名)不能夠包含數字。Excel的驅動在遇到這種問題時就會出錯(例如你的行標題名為「F1」)。如果你的Excel中某一列同時包含了文本和數字的話,那麼Excel的ODBC驅動將不能夠正常處理這一行的數據,你必須要保證該列的數據類型一致。
使用Excel做資料庫在添加數據的時候可以在本地機上使用Microsoft Excel進行編輯。書商們在做圖書數據的時候往往都是從各大出版社下載所需的圖書信息,這些圖書信息都有固定的格式,書商把下載的數據通過復制、粘貼等方法大批量的添加到Excel資料庫中。做好數據後將Excel資料庫上傳到網站。這種方法有以下優點:快速、方便和易操作。
訪問資料庫信息的第一步是和資料庫源建立連接。
使用Excel資料庫的連接方法:
<%
Dim Conn,Driver,DBPath,Rs
Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath("book.mdb")
Conn.Open Driver & DBPath
%>
其中Driver = "Driver={Microsoft Excel Driver (*.xls)};"
這一行代碼是關鍵,主要是驅動的選擇問題。我們同使用Access做資料庫的連接方法比較下便知。
<%
Dim Conn,Driver,DBPath,Rs
Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Access Driver (*.mdb)};"
DBPath = "DBQ=" & Server.MapPath("book.mdb")
Conn.Open Driver & DBPath
%>
三、 程序清單
查詢並顯示表Sheet1欄位為書名的代碼:
<%
Dim Conn,Driver,DBPath,Rs
' 建立Connection對象
Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath("book.xls")
'調用Open 方法打開資料庫
Conn.Open Driver & DBPath
'DSN連接方式
'Conn.Open "Dsn=book"
'注意 表名一定要以下邊這種格試 "[表名$]" 書寫
Sql="Select * From [Sheet1$]"
Set Rs=Conn.Execute(Sql)
IF Rs.Eof And Rs.Bof Then
Response.write "沒有找到您需要的數據!!"
Else
Do While Not Rs.EOF
Response.write Rs("書名")
Response.write "<br>"
Rs.MoveNext
Loop
End IF
Rs.Close
Set Rs=nothing
Conn.Close
Set Conn=Nothing
%>
查詢並顯示表Sheet1全部內容的代碼:
<%
Dim Conn,Driver,DBPath,Rs
Set Conn = Server.CreateObject("ADODB.Connection")
Driver = "Driver={Microsoft Excel Driver (*.xls)};"
DBPath = "DBQ=" & Server.MapPath( "book.xls" )
Conn.Open Driver & DBPath
Set Rs = Server.CreateObject("ADODB.Recordset")
Sql="select * from [Sheet1$]"
Rs.Open Sql,conn,2,2
%>
<table border="1">
<tr>
<%
for i=0 to Rs.Fields.Count-1
%>
<td bgcolor="#0099FF"><%=Rs(i).Name%></td>
<%
next
%>
</tr>
<%
do while Not Rs.EOF
%>
<tr>
<%
for i=0 to Rs.Fields.Count-1
%>
<td><%=Rs(i)%></td>
<%
next
%>
</tr>
<%
Rs.MoveNext
Loop
Rs.close
set Rs=nothing
Conn.close
set Conn=nothing
%>
</table>
四、 結論
本文主要介紹ASP編程操作Excel,實現對Excel資料庫的檢索等功能。實現方法簡單,程序代碼少,可供實用編程時借鑒使用。以上程序在Windows2000Sever及IIS5.0下運行通過.
❿ 最近發現一個可能比較有趣的問題,如何編程使程序顯示結果為其本身源碼。程序執行結果就是列印出其源碼。
/* A simple quine (self-printing program), in standard C. */
/* Note: in designing this quine, we have tried to make the code clear
* and readable, not concise and obscure as many quines are, so that
* the general principle can be made clear at the expense of length.
* In a nutshell: use the same data structure (called "progdata"
* below) to output the program code (which it represents) and its own
* textual representation. */
#include <stdio.h>
void quote(const char *s)
/* This function takes a character string s and prints the
* textual representation of s as it might appear formatted
* in C code. */
{
int i;
printf(" \"");
for (i=0; s[i]; ++i) {
/* Certain characters are quoted. */
if (s[i] == '\\')
printf("\\\\");
else if (s[i] == '"')
printf("\\\"");
else if (s[i] == '\n')
printf("\\n");
/* Others are just printed as such. */
else
printf("%c", s[i]);
/* Also insert occasional line breaks. */
if (i % 48 == 47)
printf("\"\n \"");
}
printf("\"");
}
/* What follows is a string representation of the program code,
* from beginning to end (formatted as per the quote() function
* above), except that the string _itself_ is coded as two
* consecutive '@' characters. */
const char progdata[] =
"/* A simple quine (self-printing program), in st"
"andard C. */\n\n/* Note: in designing this quine, "
"we have tried to make the code clear\n * and read"
"able, not concise and obscure as many quines are"
", so that\n * the general principle can be made c"
"lear at the expense of length.\n * In a nutshell:"
" use the same data structure (called \"progdata\"\n"
" * below) to output the program code (which it r"
"epresents) and its own\n * textual representation"
". */\n\n#include <stdio.h>\n\nvoid quote(const char "
"*s)\n /* This function takes a character stri"
"ng s and prints the\n * textual representati"
"on of s as it might appear formatted\n * in "
"C code. */\n{\n int i;\n\n printf(\" \\\"\");\n "
" for (i=0; s[i]; ++i) {\n /* Certain cha"
"racters are quoted. */\n if (s[i] == '\\\\')"
"\n printf(\"\\\\\\\\\");\n else if (s["
"i] == '\"')\n printf(\"\\\\\\\"\");\n e"
"lse if (s[i] == '\\n')\n printf(\"\\\\n\");"
"\n /* Others are just printed as such. */\n"
" else\n printf(\"%c\", s[i]);\n "
" /* Also insert occasional line breaks. */\n "
" if (i % 48 == 47)\n printf(\"\\\"\\"
"n \\\"\");\n }\n printf(\"\\\"\");\n}\n\n/* What fo"
"llows is a string representation of the program "
"code,\n * from beginning to end (formatted as per"
" the quote() function\n * above), except that the"
" string _itself_ is coded as two\n * consecutive "
"'@' characters. */\nconst char progdata[] =\n@@;\n\n"
"int main(void)\n /* The program itself... */\n"
"{\n int i;\n\n /* Print the program code, cha"
"racter by character. */\n for (i=0; progdata[i"
"]; ++i) {\n if (progdata[i] == '@' && prog"
"data[i+1] == '@')\n /* We encounter tw"
"o '@' signs, so we must print the quoted\n "
" * form of the program code. */\n {\n "
" quote(progdata); /* Quote all. */\n"
" i++; /* Skip second '"
"@'. */\n } else\n printf(\"%c\", p"
"rogdata[i]); /* Print character. */\n }\n r"
"eturn 0;\n}\n";
int main(void)
/* The program itself... */
{
int i;
/* Print the program code, character by character. */
for (i=0; progdata[i]; ++i) {
if (progdata[i] == '@' && progdata[i+1] == '@')
/* We encounter two '@' signs, so we must print the quoted
* form of the program code. */
{
quote(progdata); /* Quote all. */
i++; /* Skip second '@'. */
} else
printf("%c", progdata[i]); /* Print character. */
}
return 0;
}