首頁  >  文章  >  軟體教學  >  學習如何在Excel中使用文字辨識函數

學習如何在Excel中使用文字辨識函數

WBOY
WBOY轉載
2024-01-23 19:54:14945瀏覽

學習如何在Excel中使用文字辨識函數

如何在excel中新增一個辨識文字函數

'把它加入巨集模組裡,就可以像公式一樣使用了。

Function ColorSum(Rng As Range, Color As Range) As Double

Dim Tmp As Range

ColorSum = 0

For Each Tmp In Rng

'對選取範圍內與指定顏色相同的數字處理,排除同色的文字儲存格

If Tmp.Interior.ColorIndex = Color.Interior.ColorIndex And IsNumeric(Tmp.Value) Then

ColorSum = ColorSum Tmp.Value

End If

Next

End Function

C如何辨識檔案格式

讀取檔案頭, 可以解決問題。例如,你要查看一個圖片是否「真」的是「jpg」格式的。那就需要提取2個字節,如果檔案頭標示是「255216」就表示是「jpg」格式的。程式碼如下:

FileStream fs = new FileStream(@"C:\1.jpg", FileMode.Open, FileAccess.Read);

byte[] imagebytes = new byte[fs.Length];

BinaryReader br = new BinaryReader(fs);//二進位檔案讀取器

imagebytes = br.ReadBytes(2);//從目前流中將2個位元組讀入位元組數組

string s = "";

for (int i = 0; i {

s = imagebytes[i];

}

if(s=="255216")

Console.WriteLine("是jpg格式");

else

Console.WriteLine("不是jpg格式");

各種檔案格式檔案頭佔的位元組不一樣,譬如:jpg,2個位元組;png,8個位元組;gif,6個位元組。你只需要改變讀取的位元組數,在判斷就可以了。

如何用c語言判斷一個未知檔案的檔案類型

開啟檔案容易,讀幾個字元容易,判斷類型較難。

下面程式判斷 .exe .jpg .gif 格式

讀入的前20個位元組在 char s[20] 中。

你願意把它看成10進制,16進制都可以。

輸入形式:

可執行程式名稱 要判斷的檔案名稱

例如:

ccalb.exe file.gif

include

#include

main(int argc, char *argv[]){

FILE *fin;

char namein[80];

char s[20];

if (argc

printf("Usage: \007 %s filename\n",argv[0]);

return 0;

}

strcpy(namein,argv[1]);

fin = fopen(namein,"rb");

if (!fin){

printf("Open %s error\n",namein);

return 0;

}

fread(s,20,1,fin);

fclose(fin);

if (s[0]=='M' & s[1]=='Z') printf("It is .exe file\n");

else if (s[6]=='J' & s[7]=='F' & s[8]=='I' & s[9]=='F')printf("It is .jpg file\n");

else if (s[0]=='G' & s[1]=='I' & s[2]=='F' ) printf("It is .gif file\n");

else printf("other file");

return 0;

}###

以上是學習如何在Excel中使用文字辨識函數的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:docexcel.net。如有侵權,請聯絡admin@php.cn刪除