3 结果与讨论
我们这次自行研制的打印病理标签的程序是在我科原打印病理标签程序的基础上建立起来的,改进了原程序的不足。打印的病理切片标签清晰醒目,字体整齐美观,与原打印程序比较,感到输入打印的整个流程比较方便,我科原来使用的打印程序,输入数据时较麻烦,每个编号需要计算后输入,每个标本取了几个蜡块,需要打印几张标签需要人工计算,将数据填入对应的标签空格,我们自行设计研制的这套打印程序,病理编号可以自动生成,每例标本需打印几张标签,只需在对应的病理编号后一次性输入一个数据即可,如需10个标签则输入10,需9个标签则输入9就可以了。另外标签纸又不浪费,故特向同行朋友介绍,供参考,以期抛砖引玉。
作者单位:南京市妇幼保健院病理科,南京 210014
作者简介:密方元,男,主管技师,黄伟,男,(信息科工程师 ),E-mail:13645156103@139.com
主要程序实现vb宏部分
Private Sub CommandButton1_Click()
Dim n As Integer, y As Integer, t As Integer
Dim Str1$, Str2$, Str3$
t = 23
Dim mystr(150) As String//定义字符串数组
n = 0
Do
While t < WorksheetFunction.CountA(Range("A23:A200")) + 23//定义编辑区域
y = Sheets("Sheet1").Range("B" & t).Value
If y = 0 Then
mystr(n) = ""
n = n + 1
ElseIf y > 0 Then//初始号大于0.循环产生编号
Do While y < Sheets("Sheet1").Range("C" & t).Value + 1
If y = 1 Then
Str1$ = Sheets("Sheet1").Range("A" & t).Value
n = n + 1
y = y + 1
Loop
End If
Sheets("Sheet1").Range("E"&t).Value= Sheets("Sheet1").Range("C"&t).Value-Sheets("Sheet1").Range("B" & t).Value + 1
Sheets("Sheet1").Range("E19").Value=96-Sheets("Sheet1").Range("E21").Value + 119 - 1
t = t + 1
Loop
Dim o, q, k As Integer
o = 1
k = 0
Do While o < 13
q = 1
Do While q < 9
Sheets("Sheet1").Cells(o, q) = mystr(k)//字符串数组循环加入上部预览区域
q = q + 1
k = k + 1
Loop
o = o + 1
Loop
End Sub
XmlDocument xmlDoc1 = new XmlDocument();
xmlDoc1.Load(System.Windows.Forms.Application.StartupPath + "\\printsettings.xml");//定义打印配置文件
string Height = "";
Height = xmlDoc1.SelectSingleNode("name/Height").InnerXml;
double he = double.Parse(Height);
string Width = "";
Width = xmlDoc1.SelectSingleNode("name/Width").InnerXml;
double wi = double.Parse(Width);
string Margin = "";
Margin = xmlDoc1.SelectSingleNode("name/Margin").InnerXml;
double ma = double.Parse(Margin);
string Left = "";
Left = xmlDoc1.SelectSingleNode("name/Left").InnerXml;
double le = double.Parse(Left);
string Above = "";
Above = xmlDoc1.SelectSingleNode("name/Above").InnerXml;
double ab = double.Parse(Above);
string Fon = "";
Fon = xmlDoc1.SelectSingleNode("name/Font").InnerXml;
string Size = "";
Size = xmlDoc1.SelectSingleNode("name/Size").InnerXml;
int x = Convert.ToInt32(Size);
for (i = 0; i < 12; i++)
{
for (j = 0; j < 8; j++)
{
double t = le + ma * (j * 2 + 1) + j * he;
float n=(float)t;
double r = ab+ ma * (i * 2 + 1) + i * wi;
float k = (float)r;
e.Graphics.DrawString(abc[c], new System.Drawing.Font(Fon, x, FontStyle.Bold), Brushes.Black, n, k);
c++;
}
}
}
private void button1_Click(object sender, EventArgs e)
{
printDialog1.ShowDialog();
printPreviewDialog1.Document = this.printDocument1;
printPreviewDialog1.ShowDialog();
}
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
private void button2_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application ex = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wb = ex.Application.Workbooks.Open(System.Windows.Forms.Application.StartupPath + "\\Book1.xls", Type.Missing);
Microsoft.Office.Interop.Excel.Worksheet ws = (Microsoft.Office.Interop.Excel.Worksheet)wb.Sheets[1] as Microsoft.Office.Interop.Excel.Worksheet;
try
{
int n = 0;
int w, h;
for (h = 1; h < 13; h++)
for (w = 1; w < 9; w++)
{
abc[n] = ((Range)ex.Cells[h, w]).Text.ToString();
n++;
}
MessageBox.Show("数据同步成功|");//循环填充打印区域
}
catch
{ MessageBox.Show("数ºy据Y同ª?步?失º¡ì败㨹"); }
IntPtr y = new IntPtr(ex.Hwnd);
int z = 0;
GetWindowThreadProcessId(y, out z);
System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(z);
p.Kill();