在Excel中转​​换为文本格式

我使用excelmacros从AS400中提取一些数据。 在AS400中,这个特定的列(Ref)显示20100729000078154,但是当我解压到excel时,它将是2.01007E + 16。 我需要高达20100729000078154作为我的最终输出。 这是我用来从AS400中提取信息的macros:

Sub Extract() Dim StrSQl As String FromA = Format(Sheet1.Range("B3")) FromB = Format(Sheet1.Range("B4")) FromC = Format(Sheet1.Range("B5")) FromD = Format(Sheet1.Range("B6")) StrSQl = "select Cno,Itno,Ref from test " StrSQl = StrSQl & " where Cno= " & FromA & " and Itno like " & FromB & " and " StrSQl = StrSQl & " Ref >= " & FromC & " and Ref <= " & FromD & " " StrSQl = StrSQl & " order by Cno " con = "Provider=IBMDA400;Data Source=xxx.xxx.xxx.xxx;User Id=yyyyy;Password=zzzzz" Set Db = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.recordset") Db.ConnectionString = con Db.Open rs.Open StrSQl, Db, 3, 3 Sheet2.Cells(1, 1).CopyFromRecordset rs rs.Close Set rs = Nothing Set cn = Nothing End Sub 

如果您只希望将列显示为文本,则可以使用撇号前缀(假设在iSeries SQL中可以将单个撇号文字表示为''')…

 StrSQl = "select Cno,Itno,CONCAT('''',Ref) as Ref from test "